{"id":2911,"url":"https://patchwork.libcamera.org/api/patches/2911/?format=json","web_url":"https://patchwork.libcamera.org/patch/2911/","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":"<20200228032913.497826-2-niklas.soderlund@ragnatech.se>","date":"2020-02-28T03:29:08","name":"[libcamera-devel,RFC,1/6] libcamera: Use PixelFormat instead of unsigned int where appropriate","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"f96da38cf0e7e2f587a73e72ff72070fa046fd10","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2911/mbox/","series":[{"id":694,"url":"https://patchwork.libcamera.org/api/series/694/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=694","date":"2020-02-28T03:29:07","name":"libcamera: PixelFormat: Turn into a class","version":1,"mbox":"https://patchwork.libcamera.org/series/694/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2911/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2911/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E377760428\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 28 Feb 2020 04:29:35 +0100 (CET)","from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid 8a5a0988-59da-11ea-9f85-005056917a89;\n\tFri, 28 Feb 2020 04:29:34 +0100 (CET)"],"X-Halon-ID":"8a5a0988-59da-11ea-9f85-005056917a89","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 28 Feb 2020 04:29:08 +0100","Message-Id":"<20200228032913.497826-2-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200228032913.497826-1-niklas.soderlund@ragnatech.se>","References":"<20200228032913.497826-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC 1/6] libcamera: Use PixelFormat instead of\n\tunsigned int where appropriate","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>","X-List-Received-Date":"Fri, 28 Feb 2020 03:29:36 -0000"},"content":"Use the PixelFormat instead of unsigned int where a pixel format is to\nbe used. PixelFormat is defined as an unsigned int but is about to be\nturned into a class to add functionality.\n\nThere is no functional change in this patch.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n src/cam/main.cpp                     | 2 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 2 +-\n src/libcamera/pipeline/uvcvideo.cpp  | 4 ++--\n src/libcamera/pipeline/vimc.cpp      | 2 +-\n src/qcam/format_converter.cpp        | 2 +-\n src/qcam/format_converter.h          | 6 ++++--\n src/qcam/viewfinder.cpp              | 2 +-\n src/qcam/viewfinder.h                | 6 ++++--\n 8 files changed, 15 insertions(+), 11 deletions(-)","diff":"diff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex a38cca959aca05ff..ad4be55fc114fe22 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -281,7 +281,7 @@ int CamApp::infoConfiguration()\n \t\tstd::cout << index << \": \" << cfg.toString() << std::endl;\n \n \t\tconst StreamFormats &formats = cfg.formats();\n-\t\tfor (unsigned int pixelformat : formats.pixelformats()) {\n+\t\tfor (PixelFormat pixelformat : formats.pixelformats()) {\n \t\t\tstd::cout << \" * Pixelformat: 0x\" << std::hex\n \t\t\t\t  << std::setw(8) << pixelformat << \" \"\n \t\t\t\t  << formats.range(pixelformat).toString()\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 387bb070b5050e77..33f97b340716abd0 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -349,7 +349,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate()\n \n \tfor (unsigned int i = 0; i < config_.size(); ++i) {\n \t\tStreamConfiguration &cfg = config_[i];\n-\t\tconst unsigned int pixelFormat = cfg.pixelFormat;\n+\t\tconst PixelFormat pixelFormat = cfg.pixelFormat;\n \t\tconst Size size = cfg.size;\n \t\tconst IPU3Stream *stream;\n \ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 29afb121aa46d5d4..cf419e8b25a87389 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -107,10 +107,10 @@ CameraConfiguration::Status UVCCameraConfiguration::validate()\n \n \tStreamConfiguration &cfg = config_[0];\n \tconst StreamFormats &formats = cfg.formats();\n-\tconst unsigned int pixelFormat = cfg.pixelFormat;\n+\tconst PixelFormat pixelFormat = cfg.pixelFormat;\n \tconst Size size = cfg.size;\n \n-\tconst std::vector<unsigned int> pixelFormats = formats.pixelformats();\n+\tconst std::vector<PixelFormat> pixelFormats = formats.pixelformats();\n \tauto iter = std::find(pixelFormats.begin(), pixelFormats.end(), pixelFormat);\n \tif (iter == pixelFormats.end()) {\n \t\tcfg.pixelFormat = pixelFormats.front();\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 5d3d12fef30b01b5..93d89729e1faa29f 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -177,7 +177,7 @@ CameraConfiguration *PipelineHandlerVimc::generateConfiguration(Camera *camera,\n \n \tImageFormats formats;\n \n-\tfor (unsigned int pixelformat : pixelformats) {\n+\tfor (PixelFormat pixelformat : pixelformats) {\n \t\t/* The scaler hardcodes a x3 scale-up ratio. */\n \t\tstd::vector<SizeRange> sizes{\n \t\t\tSizeRange{ 48, 48, 4096, 2160 }\ndiff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp\nindex 383d482231400a44..368cb43fbf17ae4d 100644\n--- a/src/qcam/format_converter.cpp\n+++ b/src/qcam/format_converter.cpp\n@@ -27,7 +27,7 @@\n #define CLIP(x)\t\t\tCLAMP(x,0,255)\n #endif\n \n-int FormatConverter::configure(unsigned int format, unsigned int width,\n+int FormatConverter::configure(libcamera::PixelFormat format, unsigned int width,\n \t\t\t       unsigned int height)\n {\n \tswitch (format) {\ndiff --git a/src/qcam/format_converter.h b/src/qcam/format_converter.h\nindex 391e6a44d4ba7d4b..ff488b994ade3c3e 100644\n--- a/src/qcam/format_converter.h\n+++ b/src/qcam/format_converter.h\n@@ -9,12 +9,14 @@\n \n #include <stddef.h>\n \n+#include <libcamera/pixelformats.h>\n+\n class QImage;\n \n class FormatConverter\n {\n public:\n-\tint configure(unsigned int format, unsigned int width,\n+\tint configure(libcamera::PixelFormat format, unsigned int width,\n \t\t      unsigned int height);\n \n \tvoid convert(const unsigned char *src, size_t size, QImage *dst);\n@@ -31,7 +33,7 @@ private:\n \tvoid convertRGB(const unsigned char *src, unsigned char *dst);\n \tvoid convertYUV(const unsigned char *src, unsigned char *dst);\n \n-\tunsigned int format_;\n+\tlibcamera::PixelFormat format_;\n \tunsigned int width_;\n \tunsigned int height_;\n \ndiff --git a/src/qcam/viewfinder.cpp b/src/qcam/viewfinder.cpp\nindex d51eebb10aef8663..0ebb8edd49efd1b1 100644\n--- a/src/qcam/viewfinder.cpp\n+++ b/src/qcam/viewfinder.cpp\n@@ -44,7 +44,7 @@ QImage ViewFinder::getCurrentImage()\n \treturn image_->copy();\n }\n \n-int ViewFinder::setFormat(unsigned int format, unsigned int width,\n+int ViewFinder::setFormat(libcamera::PixelFormat format, unsigned int width,\n \t\t\t  unsigned int height)\n {\n \tint ret;\ndiff --git a/src/qcam/viewfinder.h b/src/qcam/viewfinder.h\nindex 2ba28b60345b0cb3..2668aa4457657ef9 100644\n--- a/src/qcam/viewfinder.h\n+++ b/src/qcam/viewfinder.h\n@@ -10,6 +10,8 @@\n #include <QMutex>\n #include <QWidget>\n \n+#include <libcamera/pixelformats.h>\n+\n #include \"format_converter.h\"\n \n class QImage;\n@@ -20,7 +22,7 @@ public:\n \tViewFinder(QWidget *parent);\n \t~ViewFinder();\n \n-\tint setFormat(unsigned int format, unsigned int width,\n+\tint setFormat(libcamera::PixelFormat format, unsigned int width,\n \t\t      unsigned int height);\n \tvoid display(const unsigned char *rgb, size_t size);\n \n@@ -31,7 +33,7 @@ protected:\n \tQSize sizeHint() const override;\n \n private:\n-\tunsigned int format_;\n+\tlibcamera::PixelFormat format_;\n \tunsigned int width_;\n \tunsigned int height_;\n \n","prefixes":["libcamera-devel","RFC","1/6"]}