{"id":12518,"url":"https://patchwork.libcamera.org/api/covers/12518/?format=json","web_url":"https://patchwork.libcamera.org/cover/12518/","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":"<20210608144413.1529-1-david.plowman@raspberrypi.com>","date":"2021-06-08T14:44:10","name":"[libcamera-devel,RFC,0/3] Colour spaces","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"mbox":"https://patchwork.libcamera.org/cover/12518/mbox/","series":[{"id":2111,"url":"https://patchwork.libcamera.org/api/series/2111/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2111","date":"2021-06-08T14:44:10","name":"Colour spaces","version":1,"mbox":"https://patchwork.libcamera.org/series/2111/mbox/"}],"comments":"https://patchwork.libcamera.org/api/covers/12518/comments/","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 0A02CBD22E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  8 Jun 2021 14:44:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 55A41602A0;\n\tTue,  8 Jun 2021 16:44:19 +0200 (CEST)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F7F0602A0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  8 Jun 2021 16:44:17 +0200 (CEST)","by mail-wm1-x32e.google.com with SMTP id o127so1999020wmo.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 08 Jun 2021 07:44:17 -0700 (PDT)","from pi4-davidp.pitowers.org\n\t([2a00:1098:3142:14:1ce1:9965:4328:89c4])\n\tby smtp.gmail.com with ESMTPSA id\n\ti21sm3053173wmq.12.2021.06.08.07.44.16\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 08 Jun 2021 07:44:16 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"RjIHg/np\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=ePM+hwDuxImvb2KEPajMzWyMOSgtHTl+ax5wEDDPJK8=;\n\tb=RjIHg/npSPbSVAfKzjTmLDLRvuEQfqgruldNGEpe4LXvtyQsY1EpD+2aSBUzUaaqIJ\n\tmhtO/a8isXISGe25kllZUTGttYSWXDScITTtyPcwix44uroUTtPv5hMIKgw1651W40bI\n\tNChr7Q49iJ3FaLisTM2CK6rA6LCqTR81p4wx3l0zpVGbSViPSGkKAsTAvv7fxuShNDzu\n\tFPeFYUqq6C26qFChZ03YBiQCQm9xryU8Wu0Y7Kv8cEknartn72loWIh21R9Ztj7yvMaj\n\tUJEhKVsz+svcEEM/XZHyV7xgi3en4S8Z87jz53MkWgbC1JO+nX3D38biKtwdPQyg+Ni0\n\tEbGw==","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:mime-version\n\t:content-transfer-encoding;\n\tbh=ePM+hwDuxImvb2KEPajMzWyMOSgtHTl+ax5wEDDPJK8=;\n\tb=TJbSwgESnz9bsel9YOuR0Wt7fA/gzzjsHSLI/soob+tN/ffBda1lHhFKDBuMmtEGKR\n\twBgjtC1t9jDNsF5r5yoSXFZkhsr+GJR6Zqd2qB86TOrGg0B13A+zDxPm9LpLJi+lAx2Q\n\tj3G6GWrJDI8fRKDeFb7L8BWk8zXnTo7MWI1ug9ELXN9RoeTt29r2ZGlthnivmYOyn157\n\tuwqk40MqCPeoiSWer7aWXDGO6ymkwi4vhGXtXyhBhaId0+bs4WhAUBgOKQWPHn9oSjL8\n\tgv9lL6xEwp/9JSu3ylejOOwYwFbIzusltBX8hTwVVVpQpqpinzWIbDBQZTY9JmMhIfju\n\tBxug==","X-Gm-Message-State":"AOAM533XvDgLQ8DQgeMAfSrXcDbKF9Ct030VJuHvfL2aj+tAPosijJ8M\n\td+ffem9zWfKnQ1xznqjj4vjpLu3YGh4oAqXE","X-Google-Smtp-Source":"ABdhPJyjKPH8ILxEaDGFCzhvtExRrPuOmkj7EX9uM/Tr67yq1hwBIHH0TzaBJeO3/OO7vmBV2Fod7Q==","X-Received":"by 2002:a7b:c106:: with SMTP id w6mr22230871wmi.75.1623163456725;\n\tTue, 08 Jun 2021 07:44:16 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue,  8 Jun 2021 15:44:10 +0100","Message-Id":"<20210608144413.1529-1-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [RFC PATCH 0/3] Colour spaces","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>"},"content":"Hi everyone\n\nAt this point I think it's worth having something more specific to\ndiscuss and poke holes in, so I've attached an implementation of\ncolour spaces. It roughly follows the thoughts I had outlined\npreviously. Obviously it's a bit rough and ready at the moment, I\ndon't really want to spend time polishing if we decide to do something\ncompletely different!\n\nSome things to note:\n\n* I've not filled out the necessary documentation - it seems a bit\n  early for that!\n\n* I've only included the bare minimum of colour spaces (though these\n  probably represent the vast majority of use cases, and certainly all\n  the ones the Pi handles).\n\n* It's not unlike V4L2 - it wants to know the YCbCr encoding, the\n  transfer function and the range. Though I think there's perhaps a\n  discussion to be had about the transfer function (see below).\n\n* We could include \"CUSTOM\" values for some or all of the fields. So\n  for example you might set the YCbCr encoding to \"CUSTOM\", and then\n  the class would have space for a 3x3 matrix you can fill in. (For\n  platforms that would support this.)\n\n* It doesn't deal with the CCM which converts sensor RGB to sRGB. We\n  already have a control for that. I think this would be enough (at\n  least, when a platform lets you set it)?\n\n* How about the transfer (gamma) curve? Should we have a control for\n  that, or would it make sense in here? There might be a bigger\n  discussion to have about the transfer function - how meaningful is\n  it really for cameras? Our gamma curves are always custom, and I\n  wonder if other vendors might take the same view.\n\n* I've made the colour space a per-stream thing. If there are\n  platforms that can handle this, then it may be unavoidable.\n  However, pipeline handlers will have to take care to coerce them\n  into whatever combinations they can actually support - which is I\n  think where a certain amount of fiddliness will creep in. I've tried\n  to illustrate this in the Raspberry Pi implementation, which insists\n  on the same colour space on every (non-raw) output.\n\n* There's a slightly weird YCbCr encoding called \"VIDEO\". This is just\n  a placeholder, and gets converted to a real encoding by the\n  configure() method, according to the video resolution. This makes it\n  easier for the default behaviour to \"do the right thing\" nearly all\n  the time - so that applications rarely even have to consider colour\n  spaces.\n\nThat's probably enough to get us going, so comments and discussion are\nmost welcome!\n\nThanks\nDavid\n\nDavid Plowman (3):\n  libcamera: Add ColorSpace class\n  libcamera: Support passing ColorSpaces to V4L2 drivers\n  libcamera: pipeline: raspberrypi: Support colour spaces\n\n include/libcamera/color_space.h               |  94 +++++++++++++++\n include/libcamera/internal/v4l2_videodevice.h |   2 +\n include/libcamera/meson.build                 |   1 +\n include/libcamera/stream.h                    |   3 +\n src/libcamera/color_space.cpp                 |  43 +++++++\n src/libcamera/meson.build                     |   1 +\n .../pipeline/raspberrypi/raspberrypi.cpp      |  84 +++++++++++++\n src/libcamera/v4l2_videodevice.cpp            | 112 ++++++++++++++++++\n 8 files changed, 340 insertions(+)\n create mode 100644 include/libcamera/color_space.h\n create mode 100644 src/libcamera/color_space.cpp"}