[{"id":19744,"web_url":"https://patchwork.libcamera.org/comment/19744/","msgid":"<47c719f1-1e50-637b-b672-f6225c305dab@ideasonboard.com>","date":"2021-09-21T15:01:49","subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: format_converter: Rename\n\tYUV and NV to YUVPacked and YUVSemiPlanar","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 07/09/2021 01:20, Laurent Pinchart wrote:\n> To prepare for fully-planar YUV support, rename the existing format\n> families YUV and NV to YUVPacked and YUVSemiPlanar respectively.\n> \n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/qcam/format_converter.cpp | 114 +++++++++++++++++-----------------\n>  src/qcam/format_converter.h   |   8 +--\n>  2 files changed, 61 insertions(+), 61 deletions(-)\n> \n> diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\n> index b4c7b0ca0edf..7979ea8a77ff 100644\n> --- a/src/qcam/format_converter.cpp\n> +++ b/src/qcam/format_converter.cpp\n> @@ -34,37 +34,37 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>  {\n>  \tswitch (format) {\n>  \tcase libcamera::formats::NV12:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 2;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV21:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 2;\n>  \t\tnvSwap_ = true;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV16:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV61:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = true;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV24:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 1;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV42:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 1;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = true;\n> @@ -121,22 +121,22 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>  \t\tbreak;\n>  \n>  \tcase libcamera::formats::VYUY:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 1;\n>  \t\tcb_pos_ = 2;\n>  \t\tbreak;\n>  \tcase libcamera::formats::YVYU:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 0;\n>  \t\tcb_pos_ = 3;\n>  \t\tbreak;\n>  \tcase libcamera::formats::UYVY:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 1;\n>  \t\tcb_pos_ = 0;\n>  \t\tbreak;\n>  \tcase libcamera::formats::YUYV:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 0;\n>  \t\tcb_pos_ = 1;\n>  \t\tbreak;\n> @@ -163,14 +163,14 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n>  \tcase MJPEG:\n>  \t\tdst->loadFromData(src->data(0).data(), size, \"JPEG\");\n>  \t\tbreak;\n> -\tcase YUV:\n> -\t\tconvertYUV(src, dst->bits());\n> -\t\tbreak;\n>  \tcase RGB:\n>  \t\tconvertRGB(src, dst->bits());\n>  \t\tbreak;\n> -\tcase NV:\n> -\t\tconvertNV(src, dst->bits());\n> +\tcase YUVPacked:\n> +\t\tconvertYUVPacked(src, dst->bits());\n> +\t\tbreak;\n> +\tcase YUVSemiPlanar:\n> +\t\tconvertYUVSemiPlanar(src, dst->bits());\n>  \t\tbreak;\n>  \t};\n>  }\n> @@ -185,47 +185,6 @@ static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)\n>  \t*b = CLIP(( 298 * c + 516 * d           + 128) >> RGBSHIFT);\n>  }\n>  \n> -void FormatConverter::convertNV(const Image *srcImage, unsigned char *dst)\n> -{\n> -\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n> -\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n> -\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n> -\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n> -\tconst unsigned char *src = srcImage->data(0).data();\n> -\tconst unsigned char *src_c = srcImage->data(1).data();\n> -\tint r, g, b;\n> -\n> -\tfor (unsigned int y = 0; y < height_; y++) {\n> -\t\tconst unsigned char *src_y = src + y * stride_;\n> -\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n> -\t\t\t\t\t      c_stride + cb_pos;\n> -\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n> -\t\t\t\t\t      c_stride + cr_pos;\n> -\n> -\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n> -\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> -\t\t\tdst[0] = b;\n> -\t\t\tdst[1] = g;\n> -\t\t\tdst[2] = r;\n> -\t\t\tdst[3] = 0xff;\n> -\t\t\tsrc_y++;\n> -\t\t\tsrc_cb += c_inc;\n> -\t\t\tsrc_cr += c_inc;\n> -\t\t\tdst += 4;\n> -\n> -\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> -\t\t\tdst[0] = b;\n> -\t\t\tdst[1] = g;\n> -\t\t\tdst[2] = r;\n> -\t\t\tdst[3] = 0xff;\n> -\t\t\tsrc_y++;\n> -\t\t\tsrc_cb += 2;\n> -\t\t\tsrc_cr += 2;\n> -\t\t\tdst += 4;\n> -\t\t}\n> -\t}\n> -}\n> -\n>  void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n>  {\n>  \tconst unsigned char *src = srcImage->data(0).data();\n> @@ -249,7 +208,7 @@ void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n>  \t}\n>  }\n>  \n> -void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n> +void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst)\n>  {\n>  \tconst unsigned char *src = srcImage->data(0).data();\n>  \tunsigned int src_x, src_y, dst_x, dst_y;\n> @@ -287,3 +246,44 @@ void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n>  \t\t}\n>  \t}\n>  }\n> +\n> +void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char *dst)\n> +{\n> +\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n> +\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n> +\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n> +\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n> +\tconst unsigned char *src = srcImage->data(0).data();\n> +\tconst unsigned char *src_c = srcImage->data(1).data();\n> +\tint r, g, b;\n> +\n> +\tfor (unsigned int y = 0; y < height_; y++) {\n> +\t\tconst unsigned char *src_y = src + y * stride_;\n> +\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n> +\t\t\t\t\t      c_stride + cb_pos;\n> +\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n> +\t\t\t\t\t      c_stride + cr_pos;\n> +\n> +\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n> +\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> +\t\t\tdst[0] = b;\n> +\t\t\tdst[1] = g;\n> +\t\t\tdst[2] = r;\n> +\t\t\tdst[3] = 0xff;\n> +\t\t\tsrc_y++;\n> +\t\t\tsrc_cb += c_inc;\n> +\t\t\tsrc_cr += c_inc;\n> +\t\t\tdst += 4;\n> +\n> +\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> +\t\t\tdst[0] = b;\n> +\t\t\tdst[1] = g;\n> +\t\t\tdst[2] = r;\n> +\t\t\tdst[3] = 0xff;\n> +\t\t\tsrc_y++;\n> +\t\t\tsrc_cb += 2;\n> +\t\t\tsrc_cr += 2;\n> +\t\t\tdst += 4;\n> +\t\t}\n> +\t}\n> +}\n> diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\n> index bb04aa959a1a..9ce2cc6da7f2 100644\n> --- a/src/qcam/format_converter.h\n> +++ b/src/qcam/format_converter.h\n> @@ -27,14 +27,14 @@ public:\n>  private:\n>  \tenum FormatFamily {\n>  \t\tMJPEG,\n> -\t\tNV,\n>  \t\tRGB,\n> -\t\tYUV,\n> +\t\tYUVPacked,\n> +\t\tYUVSemiPlanar,\n>  \t};\n>  \n> -\tvoid convertNV(const Image *src, unsigned char *dst);\n>  \tvoid convertRGB(const Image *src, unsigned char *dst);\n> -\tvoid convertYUV(const Image *src, unsigned char *dst);\n> +\tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n> +\tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n>  \n>  \tlibcamera::PixelFormat format_;\n>  \tunsigned int width_;\n>","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 9AC68BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Sep 2021 15:01:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1B3316918A;\n\tTue, 21 Sep 2021 17:01:54 +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 F2CD060247\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Sep 2021 17:01:52 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5CF0A2BA;\n\tTue, 21 Sep 2021 17:01:52 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"AQ7jM4kU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632236512;\n\tbh=2QlWr4/8yFJUvmRH1GhEkLy1qfQrC/dgM9H2KyB6ld0=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=AQ7jM4kUTf3sgdQY32+rg3SByOij5be8eC74D62iWxpLss0lD4VTbTlR4NX3z8R8O\n\trocti3TUdM8JDBdAMmxjmzPFIDUQT8WVnHrTN3FoW11AbhkMKuQ+rkTaUIjuR7itEi\n\trirklW9ik4vwYM7HhVMAPQ+t8e89p0XGn0ftkJmk=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210907002044.7319-1-laurent.pinchart@ideasonboard.com>\n\t<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<47c719f1-1e50-637b-b672-f6225c305dab@ideasonboard.com>","Date":"Tue, 21 Sep 2021 16:01:49 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: format_converter: Rename\n\tYUV and NV to YUVPacked and YUVSemiPlanar","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>"}},{"id":19774,"web_url":"https://patchwork.libcamera.org/comment/19774/","msgid":"<20210922070207.GI4382@pyrite.rasen.tech>","date":"2021-09-22T07:02:07","subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: format_converter: Rename\n\tYUV and NV to YUVPacked and YUVSemiPlanar","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nOn Tue, Sep 07, 2021 at 03:20:42AM +0300, Laurent Pinchart wrote:\n> To prepare for fully-planar YUV support, rename the existing format\n> families YUV and NV to YUVPacked and YUVSemiPlanar respectively.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/qcam/format_converter.cpp | 114 +++++++++++++++++-----------------\n>  src/qcam/format_converter.h   |   8 +--\n>  2 files changed, 61 insertions(+), 61 deletions(-)\n> \n> diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\n> index b4c7b0ca0edf..7979ea8a77ff 100644\n> --- a/src/qcam/format_converter.cpp\n> +++ b/src/qcam/format_converter.cpp\n> @@ -34,37 +34,37 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>  {\n>  \tswitch (format) {\n>  \tcase libcamera::formats::NV12:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 2;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV21:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 2;\n>  \t\tnvSwap_ = true;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV16:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV61:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 2;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = true;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV24:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 1;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = false;\n>  \t\tbreak;\n>  \tcase libcamera::formats::NV42:\n> -\t\tformatFamily_ = NV;\n> +\t\tformatFamily_ = YUVSemiPlanar;\n>  \t\thorzSubSample_ = 1;\n>  \t\tvertSubSample_ = 1;\n>  \t\tnvSwap_ = true;\n> @@ -121,22 +121,22 @@ int FormatConverter::configure(const libcamera::PixelFormat &format,\n>  \t\tbreak;\n>  \n>  \tcase libcamera::formats::VYUY:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 1;\n>  \t\tcb_pos_ = 2;\n>  \t\tbreak;\n>  \tcase libcamera::formats::YVYU:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 0;\n>  \t\tcb_pos_ = 3;\n>  \t\tbreak;\n>  \tcase libcamera::formats::UYVY:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 1;\n>  \t\tcb_pos_ = 0;\n>  \t\tbreak;\n>  \tcase libcamera::formats::YUYV:\n> -\t\tformatFamily_ = YUV;\n> +\t\tformatFamily_ = YUVPacked;\n>  \t\ty_pos_ = 0;\n>  \t\tcb_pos_ = 1;\n>  \t\tbreak;\n> @@ -163,14 +163,14 @@ void FormatConverter::convert(const Image *src, size_t size, QImage *dst)\n>  \tcase MJPEG:\n>  \t\tdst->loadFromData(src->data(0).data(), size, \"JPEG\");\n>  \t\tbreak;\n> -\tcase YUV:\n> -\t\tconvertYUV(src, dst->bits());\n> -\t\tbreak;\n>  \tcase RGB:\n>  \t\tconvertRGB(src, dst->bits());\n>  \t\tbreak;\n> -\tcase NV:\n> -\t\tconvertNV(src, dst->bits());\n> +\tcase YUVPacked:\n> +\t\tconvertYUVPacked(src, dst->bits());\n> +\t\tbreak;\n> +\tcase YUVSemiPlanar:\n> +\t\tconvertYUVSemiPlanar(src, dst->bits());\n>  \t\tbreak;\n>  \t};\n>  }\n> @@ -185,47 +185,6 @@ static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b)\n>  \t*b = CLIP(( 298 * c + 516 * d           + 128) >> RGBSHIFT);\n>  }\n>  \n> -void FormatConverter::convertNV(const Image *srcImage, unsigned char *dst)\n> -{\n> -\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n> -\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n> -\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n> -\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n> -\tconst unsigned char *src = srcImage->data(0).data();\n> -\tconst unsigned char *src_c = srcImage->data(1).data();\n> -\tint r, g, b;\n> -\n> -\tfor (unsigned int y = 0; y < height_; y++) {\n> -\t\tconst unsigned char *src_y = src + y * stride_;\n> -\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n> -\t\t\t\t\t      c_stride + cb_pos;\n> -\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n> -\t\t\t\t\t      c_stride + cr_pos;\n> -\n> -\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n> -\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> -\t\t\tdst[0] = b;\n> -\t\t\tdst[1] = g;\n> -\t\t\tdst[2] = r;\n> -\t\t\tdst[3] = 0xff;\n> -\t\t\tsrc_y++;\n> -\t\t\tsrc_cb += c_inc;\n> -\t\t\tsrc_cr += c_inc;\n> -\t\t\tdst += 4;\n> -\n> -\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> -\t\t\tdst[0] = b;\n> -\t\t\tdst[1] = g;\n> -\t\t\tdst[2] = r;\n> -\t\t\tdst[3] = 0xff;\n> -\t\t\tsrc_y++;\n> -\t\t\tsrc_cb += 2;\n> -\t\t\tsrc_cr += 2;\n> -\t\t\tdst += 4;\n> -\t\t}\n> -\t}\n> -}\n> -\n>  void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n>  {\n>  \tconst unsigned char *src = srcImage->data(0).data();\n> @@ -249,7 +208,7 @@ void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst)\n>  \t}\n>  }\n>  \n> -void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n> +void FormatConverter::convertYUVPacked(const Image *srcImage, unsigned char *dst)\n>  {\n>  \tconst unsigned char *src = srcImage->data(0).data();\n>  \tunsigned int src_x, src_y, dst_x, dst_y;\n> @@ -287,3 +246,44 @@ void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst)\n>  \t\t}\n>  \t}\n>  }\n> +\n> +void FormatConverter::convertYUVSemiPlanar(const Image *srcImage, unsigned char *dst)\n> +{\n> +\tunsigned int c_stride = stride_ * (2 / horzSubSample_);\n> +\tunsigned int c_inc = horzSubSample_ == 1 ? 2 : 0;\n> +\tunsigned int cb_pos = nvSwap_ ? 1 : 0;\n> +\tunsigned int cr_pos = nvSwap_ ? 0 : 1;\n> +\tconst unsigned char *src = srcImage->data(0).data();\n> +\tconst unsigned char *src_c = srcImage->data(1).data();\n> +\tint r, g, b;\n> +\n> +\tfor (unsigned int y = 0; y < height_; y++) {\n> +\t\tconst unsigned char *src_y = src + y * stride_;\n> +\t\tconst unsigned char *src_cb = src_c + (y / vertSubSample_) *\n> +\t\t\t\t\t      c_stride + cb_pos;\n> +\t\tconst unsigned char *src_cr = src_c + (y / vertSubSample_) *\n> +\t\t\t\t\t      c_stride + cr_pos;\n> +\n> +\t\tfor (unsigned int x = 0; x < width_; x += 2) {\n> +\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> +\t\t\tdst[0] = b;\n> +\t\t\tdst[1] = g;\n> +\t\t\tdst[2] = r;\n> +\t\t\tdst[3] = 0xff;\n> +\t\t\tsrc_y++;\n> +\t\t\tsrc_cb += c_inc;\n> +\t\t\tsrc_cr += c_inc;\n> +\t\t\tdst += 4;\n> +\n> +\t\t\tyuv_to_rgb(*src_y, *src_cb, *src_cr, &r, &g, &b);\n> +\t\t\tdst[0] = b;\n> +\t\t\tdst[1] = g;\n> +\t\t\tdst[2] = r;\n> +\t\t\tdst[3] = 0xff;\n> +\t\t\tsrc_y++;\n> +\t\t\tsrc_cb += 2;\n> +\t\t\tsrc_cr += 2;\n> +\t\t\tdst += 4;\n> +\t\t}\n> +\t}\n> +}\n> diff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\n> index bb04aa959a1a..9ce2cc6da7f2 100644\n> --- a/src/qcam/format_converter.h\n> +++ b/src/qcam/format_converter.h\n> @@ -27,14 +27,14 @@ public:\n>  private:\n>  \tenum FormatFamily {\n>  \t\tMJPEG,\n> -\t\tNV,\n>  \t\tRGB,\n> -\t\tYUV,\n> +\t\tYUVPacked,\n> +\t\tYUVSemiPlanar,\n>  \t};\n>  \n> -\tvoid convertNV(const Image *src, unsigned char *dst);\n>  \tvoid convertRGB(const Image *src, unsigned char *dst);\n> -\tvoid convertYUV(const Image *src, unsigned char *dst);\n> +\tvoid convertYUVPacked(const Image *src, unsigned char *dst);\n> +\tvoid convertYUVSemiPlanar(const Image *src, unsigned char *dst);\n>  \n>  \tlibcamera::PixelFormat format_;\n>  \tunsigned int width_;\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 74843BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Sep 2021 07:02:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AEB666918C;\n\tWed, 22 Sep 2021 09:02:17 +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 470CA687DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Sep 2021 09:02:16 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BC72FF1;\n\tWed, 22 Sep 2021 09:02:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rz73dVI+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1632294136;\n\tbh=w9jARGT/ZTelcwgf7lgUGhYmmYvkqs/1HbEOqp/xuBk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=rz73dVI+BMMBWKQhnMlEYQbuY1UGpJy2aWro5Yk/Zm/HNFdrg0l9WBE/G9R1cS9G3\n\tRnXyx9k5qWtYSh0tAqFV6Y84rd8ZunO2m1Y3mX+Qh3qFVNIKWbxvwknoK+RL81b+Pu\n\tQAl3DS4PGmYIaICdN6z1JVnmccCzHt0VEC0+lM+o=","Date":"Wed, 22 Sep 2021 16:02:07 +0900","From":"paul.elder@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210922070207.GI4382@pyrite.rasen.tech>","References":"<20210907002044.7319-1-laurent.pinchart@ideasonboard.com>\n\t<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20210907002044.7319-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 3/5] qcam: format_converter: Rename\n\tYUV and NV to YUVPacked and YUVSemiPlanar","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":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]