{"id":3877,"url":"https://patchwork.libcamera.org/api/1.1/covers/3877/?format=json","web_url":"https://patchwork.libcamera.org/cover/3877/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200529110335.620503-1-jacopo@jmondi.org>","date":"2020-05-29T11:03:30","name":"[libcamera-devel,0/5] ImageFormats' not dead","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/1.1/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/cover/3877/mbox/","series":[{"id":938,"url":"https://patchwork.libcamera.org/api/1.1/series/938/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=938","date":"2020-05-29T11:03:30","name":"ImageFormats' not dead","version":1,"mbox":"https://patchwork.libcamera.org/series/938/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/3877/comments/","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F45E603CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 29 May 2020 13:00:29 +0200 (CEST)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id E3410E0009;\n\tFri, 29 May 2020 11:00:28 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 29 May 2020 13:03:30 +0200","Message-Id":"<20200529110335.620503-1-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.26.2","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 0/5] ImageFormats' not dead","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, 29 May 2020 11:00:29 -0000"},"content":"Hello, this might be controversial, as ImageFormats has been a target for\ndeprecation since a long time. But as of now, it's still alive and kicking, and\nit has a few merits in my opinion, so this series tries to refactor it and its\nusers to make it nicer to work with.\n\nFirst and foremost, ImageFormats was designed to be used by both video devices\nand video subdevices, but since the introduction of V4L2PixelFormat the formats\nmap cannot be represented anymore with ImageFormats, as it indexes the image\nresolutions with a numerical index. As a consequence, pipeline handlers and\nV4L2VideoDevice fell back on using a raw map in place of ImageFormats.\n\nTo recover the situation, ImageFormats is turned into a templated class, capable\nof indexing image resolutions with keys of variadic type.\n\nThis allows reintroducing ImageFormats in V4L2VideoDevice, with its\nspecialization ImageFormats<V4l2PixelFormats>.\n\nOn top of this the last three patches renames ImageFormats, provides typedef\nfor V4L2VideoDevice and V4L2Subdevice formats and renames the formats() method\nin those classes whose name collides with ImageFormats::formats.\n\nThe new usage pattern looks like\n\nV4L2VideoDevice::formatsMap = device_->imageFormats();\nfor (const V4L2PixelFormat &v4lFormat : formatsMaps().formats()) {\n\tfor (const SizeRange &sizes : formatsMap.sizes(v4l2Format) {\n\n\t}\n}\n\ncompared to\n\nstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats = device_->formats();\nfor (const auto it: formats) {\n\tV4L2PixelFormat &v4l2Format = it.first;\n\tfor (const SizeRange &sizes : it.second) {\n\n\t}\n}\n\nWhile for subdevice it stays similar\n\nV4L2Subdevice::formatsMap formatsMap = subdev_->imageFormats();\nfor (const uint32_t code : formatsMap().formats()) {\n\tfor (const SizeRange &sizes : formatsMap.sizes(v4l2Format) {\n\n\t}\n}\n\nThanks\n   j\n\nJacopo Mondi (5):\n  libcamera: formats: Make ImageFormats a templated class\n  libcamera: v4l2_videodevice: Use ImageFormats\n  libcamera: Rename ImageFormats\n  libcamera: v4l2_device: Add formatsMap typedef\n  libcamera: v4l2_device: Rename formats() method\n\n include/libcamera/internal/camera_sensor.h    |   6 +-\n include/libcamera/internal/formats.h          |  66 ++++++++--\n include/libcamera/internal/v4l2_subdevice.h   |   4 +-\n include/libcamera/internal/v4l2_videodevice.h |   4 +-\n src/libcamera/camera_sensor.cpp               |   2 +-\n src/libcamera/formats.cpp                     | 119 +++++++++++-------\n .../pipeline/raspberrypi/raspberrypi.cpp      |  24 ++--\n src/libcamera/pipeline/simple/simple.cpp      |   3 +-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |   3 +-\n src/libcamera/v4l2_subdevice.cpp              |  11 +-\n src/libcamera/v4l2_videodevice.cpp            |   9 +-\n test/v4l2_subdevice/list_formats.cpp          |   8 +-\n 12 files changed, 175 insertions(+), 84 deletions(-)\n\n--\n2.26.2"}