From patchwork Wed Oct 20 11:08:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 14193 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 717DABDB1C for ; Wed, 20 Oct 2021 11:08:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 656B868F58; Wed, 20 Oct 2021 13:08:30 +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="lJTD/NyP"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 376736023A for ; Wed, 20 Oct 2021 13:08:28 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id l38-20020a05600c1d2600b0030d80c3667aso9245599wms.5 for ; Wed, 20 Oct 2021 04:08:28 -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=emmcpZg7Njg8rzrrkpXyEiAramO3Xg6ynLaZpz9Y4g4=; b=lJTD/NyPN2B9xEIH/O0VBL4GH0EelVKiswZaCHSEkRHm+gFzqHeQnHrXftzYR4kfEQ 15fHWxTpH+8Q99+qgHgMFzEIQXNADCaRnqaC2XX8qsxLjQLmoY4JTevuxKxHp4WPcnNs FZvyCbZK87JBq6RctaWwfvAdK7LC18P6G1Gn/v/QxUQqJEW5nGPzVgbbAKrl+EEueB3+ Ko2nlFHURuFeH5vNsGRLN0Jy1oFn/z+o/jUA6jP0hrwGasEiB+kuQPTDLHZwFzwg9hjE RC4VpXqlr3eOuNyjMrjyvrGDuQA7dEb9shuEkFU+pxchYx4VOaN8PEfa226EwLDj9sS4 46XA== 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=emmcpZg7Njg8rzrrkpXyEiAramO3Xg6ynLaZpz9Y4g4=; b=Dko8CcgAGjwygRsUv4OvjVEAno5Q6QSfloLHjEtu3yqgXSyF/oacvvVIWUodcouXcr NNwUy7Pw1H6dF1yBJX4AF+dUu3u4UQLgom6qJHoAysQLP3xgOmK6vFXeNXzX6w/Oc00l O4WKUnMC3ZnPhXwuyUM1bj+n1AxapVWFNJLU+50OLTFLm80ObOW3WakjotKqEZD01/HN 68/nTh+5XP5WrLu8KFcpLHfHyY3fwMHW6pJioo2F0tMMklIHYqi4DszTL5BfSPcZLzkp STXoTnRpkrwF1SO0QzZA0LxhqRXxKfUGFCG+0bcAQpDkNBQlp1S8xUh9vY09CMary3d4 6t5w== X-Gm-Message-State: AOAM530FEUenOXexAw3dawMP3aHn0cruImp+YUNpNDqsRQ90aUIzXTOX uXWo2hcsvljAHztYVS6ocHw1zZgrPucXWw== X-Google-Smtp-Source: ABdhPJxWEt8qLJGNlcvs8E6AEPfFgdthIy85Mf26RS7ArR3LEnkPlWvhavHwGpguQ+cVp728m6+bZA== X-Received: by 2002:adf:a4d5:: with SMTP id h21mr51125662wrb.203.1634728107507; Wed, 20 Oct 2021 04:08:27 -0700 (PDT) Received: from pi4-davidp.pitowers.org ([2a00:1098:3142:14:1ce1:9965:4328:89c4]) by smtp.gmail.com with ESMTPSA id f20sm1929654wmq.38.2021.10.20.04.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 04:08:27 -0700 (PDT) From: David Plowman To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Oct 2021 12:08:18 +0100 Message-Id: <20211020110825.12902-1-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 everyone Here's a new version of the colour space patches. A huge amount has changed, even since I last discussed it with folks! 1. The ColorSpace class There's a ColorSpace class with 4 enums, one for each of: the colour primaries, the Y'CbCr encoding, the transfer function and the range (quantisation). Notes: - There are no "default" values at all. Every standard colour space has a unique representation in terms of these enums. - But each enum does have an "undefined" value, in case a driver framework (such as V4L2) uses something that the ColorSpace class does not recognise. - It's conceivable that the class could be extended in future by using a "custom" enum value and then adding further fields (such as colour primaries or transfer functions). But this is out-of-scope for now. 2. Stream configurations The StreamConfiguration contains two ColorSpace fields, the one an application wants (the "requested" colour space) and the one it will get (the "actual" colour space), which is filled in by the validate() method. Notes: - The requested colour space may never contain "undefined" values, though the actual colour space, returned by the system, may. - The reason for having two fields is so that we don't change the requested colour space, which would make the configuration harder to use later, or to change and re-validate. - I've moved away from allowing colour spaces to be "unset". I couldn't really figure out how this would play nicely with validate() and configure(), and it does make the whole thing easier to understand. 3. Pipeline handlers In generateConfiguration, pipeline handlers should set ColorSpace::Jpeg for stills and ColorSpace::Rec709 for video. Application code must be aware of this, and overwrite these values if they want something different. Then validate() should call the new validateColorSpaces method which checks the requested colour spaces. Ideally, pipeline handlers will then go on to verify whether the requested colour spaces are actually supported. As regards ipu3/rkisp1, I can easily add commits for those first simple changes if it would be helpful. Beyond that, verifying what the hardware will really do is probably best left to someone who understands those pipelines! Thanks, and sorry that this is all so long! 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 | 53 ++++ src/libcamera/camera_sensor.cpp | 1 + src/libcamera/color_space.cpp | 256 ++++++++++++++++++ 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 | 37 ++- src/libcamera/v4l2_videodevice.cpp | 69 ++++- 16 files changed, 755 insertions(+), 6 deletions(-) create mode 100644 include/libcamera/color_space.h create mode 100644 src/libcamera/color_space.cpp