From patchwork Mon Nov 15 16:11:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 14606 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 5880DBF415 for ; Mon, 15 Nov 2021 16:13:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 746196038B; Mon, 15 Nov 2021 17:12:59 +0100 (CET) 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="Kc02VjmY"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 62F5E60233 for ; Mon, 15 Nov 2021 17:12:57 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id z1-20020a05600c220100b00337f97d2464so147176wml.1 for ; Mon, 15 Nov 2021 08:12:57 -0800 (PST) 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=0eCGZCtOMNNAcKBSY7zzcKCySiykmjRzz1eWqQG4Erg=; b=Kc02VjmYppD+ZTUlLvqc2boyQO0wBE+CxGPCN5bNmtoUwsTulCK89mAMTVWW5rBWMg 1+tcU7u3McFgI7vC4AB6iS++vhy6j8+0NFAWGhIgtEv+06khSyiuQHA7LcCAFPI0XgIA rzWFqOzesKmsBMOAyd74P9kEwaz7iuLngurEhffmjscvFu+LgrJo/DJO3/PCbXgFtV6w BEsKAGswP53V/f8GOp0GUFt/74WjF9/qL7LEUK324MqF8dyUmtTFO0YX4TUD2BwpUUmX urmufVTXDJNZt9mPwMQ3AsLjYDXauXHkCg7wVLB6C5tRGNR9HRzTRY7QHZKD8jje8KGj L0gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=0eCGZCtOMNNAcKBSY7zzcKCySiykmjRzz1eWqQG4Erg=; b=eo1rSFzI1rf77wCdAQQH/a1xcQ0Q81/nQYRV6hHnlt7GmNA7bwZ/B9rFhoovrM8tJr TPITTIDtqjHIvnd0i42N5p4y+9NWFSc9Xfdr1sH3/Td0V17CPjBkhIJc0HS/Oh/DicbZ nfoJyLBtc2ITYpGDgo+ZtPV/oFk3P7koRAuGOWBxURtAiIWH1L6q6ppI4lbQJK/1/JR7 C9o54V9S3ddWWGpDaS2yfUZw08RxfZJUW12NjGtt1Ne2TSkT+ZrJKelWQuGxXvOSepZS g7HtlV+Cp79mmMnnm79pnnlp/jg78mmV6kg2KmDAd8bNxPtxdebzxtGePtINncIjVs6d w0vQ== X-Gm-Message-State: AOAM532jty7x0NnWUBCdj8duVyj4eSghoiLs2jRIKMywGKCoL5mYfRhQ 5ZUDjcKlZ5usJHFy+exCnLLgKQ== X-Google-Smtp-Source: ABdhPJz8YHWz+53s2fvJPy6Sm5mCmrutQadmppVUeMNwgb4mrVPD6EEzkv5dsDY84efCCYTVkx0WWg== X-Received: by 2002:a05:600c:4e01:: with SMTP id b1mr13145258wmq.109.1636992776973; Mon, 15 Nov 2021 08:12:56 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id j40sm16315615wms.16.2021.11.15.08.12.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Nov 2021 08:12:56 -0800 (PST) From: David Plowman To: hverkuil-cisco@xs4all.nl, laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com, jacopo@jmondi.org, tfiga@google.com, naush@raspberrypi.com, libcamera-devel@lists.libcamera.org Date: Mon, 15 Nov 2021 16:11:58 +0000 Message-Id: <20211115161205.24335-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 0/7] 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 This is a re-post of this patch set with an increased distribution list. For the moment I would say the "code details" are not so important as those can be sorted out later, it's the basic ideas here that we need to get right first. To try and summarise those: 1. There's a ColorSpace class consisting of 4 enums, for the primaries, the Y'CbCr encoding, the transfer function and the quantisation (range). 2. Every colour space has just one representation in terms of these four enums. 3. I've insisted that pipeline handlers must say what colour space they want. I'm nervous about letting people "not say", and then you get a slightly wrong colour space and never notice! 4. I'm worried about drivers (in future, perhaps) wanting to use colour spaces that aren't listed in the ColorSpace class. Do I worry too much? 5. Point 4 led me to having two ColorSpace fields in the configuration object, one for the "colour space you want", and one for "what the driver will give you". 6. Again, because of point 4, I've allowed the "what the driver will give you" colour space to be "undefined". But you _may not_ pass "undefined" as the "colour space you want". 7. Whenever colour spaces don't match up I think there need to be warnings that are hard to ignore, because it's so easy to get colour spaces wrong (and never notice). At the same time, outright failure seems unhelpful because there really could be times when you can't have the colour space you really want. 8. I've suggested pipeline handlers should pick reasonable defaults in their generateConfiguration() methods. Perhaps JPEG for stills, and Rec.709 for video. 9. I do wonder about a future where people might want to specify custom colour spaces (obviously there'd have to be driver support). I imagine that happening through a "Custom" value for some of the enums, and then extra fields which are then "active". For example, you might specify your 3 colour primaries. I think that's it. If I can clarify anything further between now and Wednesday, please don't hesitate to ask. Best regards David David Plowman (7): libcamera: Add ColorSpace class libcamera: Add ColorSpace fields to StreamConfiguration libcamera: Convert between ColorSpace class and V4L2 formats libcamera: Support passing ColorSpaces to V4L2 video devices libcamera: Support passing ColorSpaces to V4L2 subdevices libcamera: Add validateColorSpaces to CameraConfiguration class libcamera: pipeline: raspberrypi: Support color spaces include/libcamera/camera.h | 2 + include/libcamera/color_space.h | 88 ++++++ include/libcamera/internal/v4l2_device.h | 7 + include/libcamera/internal/v4l2_subdevice.h | 2 + include/libcamera/internal/v4l2_videodevice.h | 2 + include/libcamera/meson.build | 1 + include/libcamera/stream.h | 4 + src/libcamera/camera.cpp | 51 ++++ src/libcamera/camera_sensor.cpp | 1 + src/libcamera/color_space.cpp | 257 ++++++++++++++++++ src/libcamera/meson.build | 1 + .../pipeline/raspberrypi/raspberrypi.cpp | 42 +++ src/libcamera/stream.cpp | 25 ++ src/libcamera/v4l2_device.cpp | 171 ++++++++++++ src/libcamera/v4l2_subdevice.cpp | 42 ++- src/libcamera/v4l2_videodevice.cpp | 67 ++++- 16 files changed, 758 insertions(+), 5 deletions(-) create mode 100644 include/libcamera/color_space.h create mode 100644 src/libcamera/color_space.cpp