From patchwork Tue Jun 8 14:44:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 12518 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0A02CBD22E for ; Tue, 8 Jun 2021 14:44:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55A41602A0; Tue, 8 Jun 2021 16:44:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="RjIHg/np"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F7F0602A0 for ; Tue, 8 Jun 2021 16:44:17 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id o127so1999020wmo.4 for ; Tue, 08 Jun 2021 07:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ePM+hwDuxImvb2KEPajMzWyMOSgtHTl+ax5wEDDPJK8=; b=RjIHg/npSPbSVAfKzjTmLDLRvuEQfqgruldNGEpe4LXvtyQsY1EpD+2aSBUzUaaqIJ mhtO/a8isXISGe25kllZUTGttYSWXDScITTtyPcwix44uroUTtPv5hMIKgw1651W40bI NChr7Q49iJ3FaLisTM2CK6rA6LCqTR81p4wx3l0zpVGbSViPSGkKAsTAvv7fxuShNDzu FPeFYUqq6C26qFChZ03YBiQCQm9xryU8Wu0Y7Kv8cEknartn72loWIh21R9Ztj7yvMaj UJEhKVsz+svcEEM/XZHyV7xgi3en4S8Z87jz53MkWgbC1JO+nX3D38biKtwdPQyg+Ni0 EbGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ePM+hwDuxImvb2KEPajMzWyMOSgtHTl+ax5wEDDPJK8=; b=TJbSwgESnz9bsel9YOuR0Wt7fA/gzzjsHSLI/soob+tN/ffBda1lHhFKDBuMmtEGKR wBgjtC1t9jDNsF5r5yoSXFZkhsr+GJR6Zqd2qB86TOrGg0B13A+zDxPm9LpLJi+lAx2Q j3G6GWrJDI8fRKDeFb7L8BWk8zXnTo7MWI1ug9ELXN9RoeTt29r2ZGlthnivmYOyn157 uwqk40MqCPeoiSWer7aWXDGO6ymkwi4vhGXtXyhBhaId0+bs4WhAUBgOKQWPHn9oSjL8 gv9lL6xEwp/9JSu3ylejOOwYwFbIzusltBX8hTwVVVpQpqpinzWIbDBQZTY9JmMhIfju Bxug== X-Gm-Message-State: AOAM533XvDgLQ8DQgeMAfSrXcDbKF9Ct030VJuHvfL2aj+tAPosijJ8M d+ffem9zWfKnQ1xznqjj4vjpLu3YGh4oAqXE X-Google-Smtp-Source: ABdhPJyjKPH8ILxEaDGFCzhvtExRrPuOmkj7EX9uM/Tr67yq1hwBIHH0TzaBJeO3/OO7vmBV2Fod7Q== X-Received: by 2002:a7b:c106:: with SMTP id w6mr22230871wmi.75.1623163456725; Tue, 08 Jun 2021 07:44:16 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id i21sm3053173wmq.12.2021.06.08.07.44.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 07:44:16 -0700 (PDT) From: David Plowman 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 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Hi everyone At this point I think it's worth having something more specific to discuss and poke holes in, so I've attached an implementation of colour spaces. It roughly follows the thoughts I had outlined previously. Obviously it's a bit rough and ready at the moment, I don't really want to spend time polishing if we decide to do something completely different! Some things to note: * I've not filled out the necessary documentation - it seems a bit early for that! * I've only included the bare minimum of colour spaces (though these probably represent the vast majority of use cases, and certainly all the ones the Pi handles). * It's not unlike V4L2 - it wants to know the YCbCr encoding, the transfer function and the range. Though I think there's perhaps a discussion to be had about the transfer function (see below). * We could include "CUSTOM" values for some or all of the fields. So for example you might set the YCbCr encoding to "CUSTOM", and then the class would have space for a 3x3 matrix you can fill in. (For platforms that would support this.) * It doesn't deal with the CCM which converts sensor RGB to sRGB. We already have a control for that. I think this would be enough (at least, when a platform lets you set it)? * How about the transfer (gamma) curve? Should we have a control for that, or would it make sense in here? There might be a bigger discussion to have about the transfer function - how meaningful is it really for cameras? Our gamma curves are always custom, and I wonder if other vendors might take the same view. * I've made the colour space a per-stream thing. If there are platforms that can handle this, then it may be unavoidable. However, pipeline handlers will have to take care to coerce them into whatever combinations they can actually support - which is I think where a certain amount of fiddliness will creep in. I've tried to illustrate this in the Raspberry Pi implementation, which insists on the same colour space on every (non-raw) output. * There's a slightly weird YCbCr encoding called "VIDEO". This is just a placeholder, and gets converted to a real encoding by the configure() method, according to the video resolution. This makes it easier for the default behaviour to "do the right thing" nearly all the time - so that applications rarely even have to consider colour spaces. That's probably enough to get us going, so comments and discussion are most welcome! Thanks David David Plowman (3): libcamera: Add ColorSpace class libcamera: Support passing ColorSpaces to V4L2 drivers libcamera: pipeline: raspberrypi: Support colour spaces include/libcamera/color_space.h | 94 +++++++++++++++ include/libcamera/internal/v4l2_videodevice.h | 2 + include/libcamera/meson.build | 1 + include/libcamera/stream.h | 3 + src/libcamera/color_space.cpp | 43 +++++++ src/libcamera/meson.build | 1 + .../pipeline/raspberrypi/raspberrypi.cpp | 84 +++++++++++++ src/libcamera/v4l2_videodevice.cpp | 112 ++++++++++++++++++ 8 files changed, 340 insertions(+) create mode 100644 include/libcamera/color_space.h create mode 100644 src/libcamera/color_space.cpp