{"id":1159,"url":"https://patchwork.libcamera.org/api/patches/1159/?format=json","web_url":"https://patchwork.libcamera.org/patch/1159/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190504203354.20870-1-paul.elder@ideasonboard.com>","date":"2019-05-04T20:33:53","name":"[libcamera-devel,1/2] qcam: format_converter: Add formatFamily enum","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1d695583c906240cdc01815ae09750b1a20546bc","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/1159/mbox/","series":[{"id":297,"url":"https://patchwork.libcamera.org/api/series/297/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=297","date":"2019-05-04T20:33:53","name":"[libcamera-devel,1/2] qcam: format_converter: Add formatFamily enum","version":1,"mbox":"https://patchwork.libcamera.org/series/297/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/1159/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/1159/checks/","tags":{},"headers":{"Return-Path":"<paul.elder@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CD81860E54\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 May 2019 22:34:10 +0200 (CEST)","from localhost.localdomain (unknown [96.44.9.117])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CB50ED5;\n\tSat,  4 May 2019 22:34:09 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1557002050;\n\tbh=FPP91rWSqJ3l1bSo7B0dzdZZk7e5xiWmXoNgWofCbB8=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=S9KauegDfJTFLxJCgrG4MnfaprzaOkRLw2/P56Kbc7Vw4qO0S8Rk14zUZd7c9e7jR\n\tfZ0LnUfYXL1vad50vfb/8D8D7LyPVJh4R7PVOkrBKdsT5P0n5P9sa8EBDushZXEXP5\n\th5I+FyC5F31baHLXUwdsEDyu40Qi06Uw+6EzbxsI=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 May 2019 16:33:53 -0400","Message-Id":"<20190504203354.20870-1-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 1/2] qcam: format_converter: Add\n\tformatFamily enum","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sat, 04 May 2019 20:34:11 -0000"},"content":"It is not sustainable to add a new flag for every new video format\nfamily (eg. YUYV, RGB, NV, MJPEG, etc), so add a formatFamily enum to\nindicate these in the FormatConverter.\n\nNote that formats are grouped into families based on if they are able to\nshare a set of parameters for conversion.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n src/qcam/format_converter.cpp | 27 ++++++++++++++++-----------\n src/qcam/format_converter.h   | 11 ++++++++++-\n 2 files changed, 26 insertions(+), 12 deletions(-)","diff":"diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex d9088c3..192767c 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -32,48 +32,48 @@ int FormatConverter::configure(unsigned int format, unsigned int width,\n {\n \tswitch (format) {\n \tcase V4L2_PIX_FMT_BGR24:\n-\t\tyuv_ = false;\n+\t\tformatFamily_ = RGB;\n \t\tr_pos_ = 2;\n \t\tg_pos_ = 1;\n \t\tb_pos_ = 0;\n \t\tbpp_ = 3;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_RGB24:\n-\t\tyuv_ = false;\n+\t\tformatFamily_ = RGB;\n \t\tr_pos_ = 0;\n \t\tg_pos_ = 1;\n \t\tb_pos_ = 2;\n \t\tbpp_ = 3;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_ARGB32:\n-\t\tyuv_ = false;\n+\t\tformatFamily_ = RGB;\n \t\tr_pos_ = 1;\n \t\tg_pos_ = 2;\n \t\tb_pos_ = 3;\n \t\tbpp_ = 4;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_VYUY:\n-\t\tyuv_ = true;\n+\t\tformatFamily_ = YUV;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 2;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_YVYU:\n-\t\tyuv_ = true;\n+\t\tformatFamily_ = YUV;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 3;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_UYVY:\n-\t\tyuv_ = true;\n+\t\tformatFamily_ = YUV;\n \t\ty_pos_ = 1;\n \t\tcb_pos_ = 0;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_YUYV:\n-\t\tyuv_ = true;\n+\t\tformatFamily_ = YUV;\n \t\ty_pos_ = 0;\n \t\tcb_pos_ = 1;\n \t\tbreak;\n \tcase V4L2_PIX_FMT_MJPEG:\n-\t\tyuv_ = false;\n+\t\tformatFamily_ = MJPEG;\n \t\tbreak;\n \tdefault:\n \t\treturn -EINVAL;\n@@ -89,12 +89,17 @@ int FormatConverter::configure(unsigned int format, unsigned int width,\n void FormatConverter::convert(const unsigned char *src, size_t size,\n \t\t\t      QImage *dst)\n {\n-\tif (format_ == V4L2_PIX_FMT_MJPEG)\n+\tswitch (formatFamily_) {\n+\tcase MJPEG:\n \t\tdst->loadFromData(src, size, \"JPEG\");\n-\telse if (yuv_)\n+\t\tbreak;\n+\tcase YUV:\n \t\tconvertYUV(src, dst->bits());\n-\telse\n+\t\tbreak;\n+\tcase RGB:\n \t\tconvertRGB(src, dst->bits());\n+\t\tbreak;\n+\t};\n }\n \n void FormatConverter::convertRGB(const unsigned char *src, unsigned char *dst)\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex 76cd9f1..9820982 100644\n--- a/src/qcam/format_converter.h\n+++ b/src/qcam/format_converter.h\n@@ -14,6 +14,12 @@ class QImage;\n class FormatConverter\n {\n public:\n+\tenum formatFamily {\n+\t\tMJPEG,\n+\t\tRGB,\n+\t\tYUV,\n+\t};\n+\n \tint configure(unsigned int format, unsigned int width,\n \t\t      unsigned int height);\n \n@@ -27,12 +33,15 @@ private:\n \tunsigned int width_;\n \tunsigned int height_;\n \n+\tenum formatFamily formatFamily_;\n+\n+\t/* RGB parameters */\n \tunsigned int bpp_;\n \tunsigned int r_pos_;\n \tunsigned int g_pos_;\n \tunsigned int b_pos_;\n \n-\tbool yuv_;\n+\t/* YUV parameters */\n \tunsigned int y_pos_;\n \tunsigned int cb_pos_;\n };\n","prefixes":["libcamera-devel","1/2"]}