[{"id":27856,"web_url":"https://patchwork.libcamera.org/comment/27856/","msgid":"<20230924131351.GO19112@pendragon.ideasonboard.com>","date":"2023-09-24T13:13:51","subject":"Re: [libcamera-devel] [PATCH RFC 0/7] android: add YUYV->NV12\n\tconversion via libyuv","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Mattijs,\n\nOn Fri, Sep 15, 2023 at 09:57:24AM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n> On some platforms, it's possible that the gralloc implementation\n> and the CSI receiver cannot agree on a pixel format.\n> When that happens, there is usually a m2m converter in the pipeline\n> which handles pixel format conversion.\n> \n> On platforms without pixel format converters, such as the AM62x,\n> we need to do software conversion.\n> \n> The AM62x platform:\n> * uses a CSI receiver (j721e-csi2rx), that only supports\n>   packed YUV422 formats such as YUYV, YVYU, UYVY and VYUY.\n> * Has a gralloc implementation that only supports of semi-planar\n>   YUV420 formats such as NV12.\n\n:-(\n\nIs this because the display hardware doesn't support YUYV, or because\nit's not implement in TI's gralloc ? A quick look at the TRM shows that\nthe DSS supports packed YUV inputs.\n\n> This series add support for software conversion using libyuv.\n> Right now, only YUYV->NV12 is supported.\n> \n> This has been send as an RFC because:\n> \n> 1. I don't have much media knowledge, nor C++ knowledge so this is\n>    probably not good enough for libcamera's high quality codebase.\n\nI'll take that as a compliment, but there's no need to denigrate your\nskills like that :-)\n\n> 2. I'm not sure that transforming the \"main Type::Direct\" stream into\n>    an Internal stream has no side effects.\n> \n> 3. I'm unsure what to do with the gralloc size in case of conversion.\n>    Right now, we always allocate HAL_PIXEL_FORMAT_YCBCR_420_888 in\n>    CameraStream::getBuffer(). This should be adapted both on:\n>    - the gralloc capabilities of the platform\n>    - the conversion (if any)\n> \n> This has been tested on a AM62x SK EVM board with an Alinx\n> AN5641 (ov5640) sensor.\n\nThat sensor should have disappeared a looooong time ago...\n\n> In Android 13.\n> It might work on BeaglePlay with the same sensor, but I have not\n> tested that.\n> \n> Both preview and still capture are functional with the\n> default com.android.camera2 app.\n> Note that video recording is not supported, because that would require\n> a similar conversion from YUYV->MJPEG which I did not investigate yet.\n> \n> I would appreciate some feedback. Thanks a lot in advance if you\n> have a look!\n> \n> Depends on:\n> - https://patchwork.libcamera.org/cover/18995/\n> \n> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> ---\n> Mattijs Korpershoek (7):\n>       android: yuv: separate source destination in length check\n>       android: yuv: loop over each plane for size check\n>       android: yuv: prepare support for other pixel formats\n>       android: camera_device: support when no Direct stream is found\n>       android: camera_stream: add add explicit input configuration\n>       android: yuv: add YUYV -> NV12 conversion\n>       WIP: android: add YUYV->NV12 format conversion via libyuv\n> \n>  src/android/camera_capabilities.cpp    |  90 ++++++++++++++++++-\n>  src/android/camera_capabilities.h      |   4 +\n>  src/android/camera_device.cpp          |   9 +-\n>  src/android/camera_stream.cpp          |  57 +++++++++++-\n>  src/android/camera_stream.h            |   5 ++\n>  src/android/yuv/post_processor_yuv.cpp | 156 ++++++++++++++++++++++-----------\n>  src/android/yuv/post_processor_yuv.h   |  12 ++-\n>  7 files changed, 270 insertions(+), 63 deletions(-)\n> ---\n> base-commit: 58e501c71c47e57f02afde1bd296a037038cd6d5\n> change-id: 20230914-libyuv-convert-fec7082343e4","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 E04A1BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 24 Sep 2023 13:13:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32DBC62944;\n\tSun, 24 Sep 2023 15:13:41 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7941B62916\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 24 Sep 2023 15:13:40 +0200 (CEST)","from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi\n\t[213.243.189.158])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D8701128D;\n\tSun, 24 Sep 2023 15:12:00 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695561221;\n\tbh=1Tc9KhYYSyAYz8MbeXsh7gVRE1ow/tI/YtraoscrFA4=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=BGcfOeuGWo7gssEdrttcQkt8LxviIQFVNcy+TtRfwS2W8wGVJedl4K6BjrPjBBt3j\n\tTBZwZrV6lYgU0p+9iPOuTs5oWYP+5J0suydnHwI7U2/8ev6ZE7Va18I+myx9QebIoX\n\tDVCKfeO0Bcf6v7lzyd4n09BfTSF0iZKxOtOP6jqoSHX1gFHkH0q6CrBkKbu5CBRxPf\n\tsa16eXCiN+I1ko4HL8I0Ib2t8JFaWC4ja3k74WLS/NYDVTt73AuxeI+GnbBqrR4Sw/\n\tusck53GzTgapAx6QUtKApddBT9gj+oM1BCRXrBVoCzCxGNKlZkt26HXz8XdPkcs6IU\n\tK/x5FVgztCO3g==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695561121;\n\tbh=1Tc9KhYYSyAYz8MbeXsh7gVRE1ow/tI/YtraoscrFA4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Rsn8wAOasTeS0m3Pg6k7HUobbnrC3d4QMnBFVgMbqkL8KHJUl0O5ZBmF79LB/GuzP\n\t4ps3I0uWFpd7dwwwWz4RFTDxRKmFNmiQ2cSf+W0Ulg9mloxYrXmBLUrXTpd+9GPVOF\n\tv8ixSE0h+UYyMx2/3JCJXEt5a2Vda0NYZbLCwIe8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Rsn8wAOa\"; dkim-atps=neutral","Date":"Sun, 24 Sep 2023 16:13:51 +0300","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Message-ID":"<20230924131351.GO19112@pendragon.ideasonboard.com>","References":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230915-libyuv-convert-v1-0-1e5bcf68adac@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH RFC 0/7] android: add YUYV->NV12\n\tconversion via libyuv","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]