[{"id":28336,"web_url":"https://patchwork.libcamera.org/comment/28336/","msgid":"<170265115894.3044059.5110597091748483875@ping.linuxembedded.co.uk>","date":"2023-12-15T14:39:18","subject":"Re: [libcamera-devel] cam: Support RGB888 texture in sdl sink","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Pavel Machek (2023-12-12 17:36:30)\n>     \n> Briefly tested on PinePhone, it is useful for SoftISP testing.\n\nCommit messages should ideally describe the code change. Perhaps:\n\n\"\"\"\nSDL Supports SDL_PIXELFORMAT_BGR24 which maps directly to the libcamera\npixelformat RGB888.\n\nAdd this to enable rendering RGB single planar image formats with SDL.\n\"\"\"\n\nI would suggest this could be tested with VIMC which can produce both\nRGB888 and BGR888 as far as I can recall.\n\nAnd probably both formats should be tested and added. (with the commit\nmessage reflecting both formats then)\n\n\n>     \n> Signed-off-by: Pavel Machek <pavel@ucw.cz>\n> \n> diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp\n> index a2f4abc1..105fa781 100644\n> --- a/src/apps/cam/sdl_sink.cpp\n> +++ b/src/apps/cam/sdl_sink.cpp\n> @@ -76,6 +76,9 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n>         case libcamera::formats::YUYV:\n>                 texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);\n>                 break;\n> +       case libcamera::formats::RGB888:\n> +               texture_ = std::make_unique<SDLTextureRGB888>(rect_, cfg.stride);\n> +               break;\n>         default:\n>                 std::cerr << \"Unsupported pixel format \"\n>                           << cfg.pixelFormat.toString() << std::endl;\n> diff --git a/src/apps/cam/sdl_texture_yuv.cpp b/src/apps/cam/sdl_texture_yuv.cpp\n> index b29c3b93..bb066540 100644\n> --- a/src/apps/cam/sdl_texture_yuv.cpp\n> +++ b/src/apps/cam/sdl_texture_yuv.cpp\n\nI don't think RGB888 should be within  texture_yuy.cpp file though.\n\nEither we break out to sdl_texture_rgb.cpp (and perhaps add both RGB888\nand BGR888 to get started) or we should rename sdl_texture_yuv to\nsomething more appropriate.\n\n\n\n> @@ -31,3 +31,13 @@ void SDLTextureYUYV::update(const std::vector<libcamera::Span<const uint8_t>> &d\n>  {\n>         SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_);\n>  }\n> +\n> +SDLTextureRGB888::SDLTextureRGB888(const SDL_Rect &rect, unsigned int stride)\n> +       : SDLTexture(rect, SDL_PIXELFORMAT_BGR24, stride)\n> +{\n> +}\n> +\n> +void SDLTextureRGB888::update(const std::vector<libcamera::Span<const uint8_t>> &data)\n> +{\n> +       SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_);\n> +}\n> diff --git a/src/apps/cam/sdl_texture_yuv.h b/src/apps/cam/sdl_texture_yuv.h\n> index 310e4e50..0df6b445 100644\n> --- a/src/apps/cam/sdl_texture_yuv.h\n> +++ b/src/apps/cam/sdl_texture_yuv.h\n> @@ -24,3 +24,10 @@ public:\n>         SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride);\n>         void update(const std::vector<libcamera::Span<const uint8_t>> &data) override;\n>  };\n> +\n> +class SDLTextureRGB888 : public SDLTexture\n> +{\n> +public:\n> +       SDLTextureRGB888(const SDL_Rect &rect, unsigned int stride);\n> +       void update(const std::vector<libcamera::Span<const uint8_t>> &data) override;\n> +};\n> \n> -- \n> People of Russia, stop Putin before his war on Ukraine escalates.","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 61C9ABD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Dec 2023 14:39:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E613362B33;\n\tFri, 15 Dec 2023 15:39:22 +0100 (CET)","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 D23FB62B2A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Dec 2023 15:39:21 +0100 (CET)","from pendragon.ideasonboard.com\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F12FEE62;\n\tFri, 15 Dec 2023 15:38:34 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1702651162;\n\tbh=H2afZgnbD7m3KtMjiKwtuIftrqoh7TPVfHzRErjOCXo=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=mqBCaknP7ZyNa4HgGNDTa9sbwsw8P0t8Hry316VpKArGrIauPqFdqwnePERHAR08x\n\tHVR+NbC9G7v9wLvxMTQCsr3MXpqN9n4Wch0L9P3pJ8l9s3iIYJFASVRhY5ay162SVw\n\t1HRtYaCm0HldmBhozffou+S6JRYY1wpQZsi8jDgLLYBBpIrao8f/uCoxjw+5AKHM0P\n\tJbcvJ7iHoq90zU0eHerJMYoSyIffBLL8SYd7UjEOD8zh/6RtlOtxtzTtxNYqlYKXRV\n\tuM9InHpOe0ifTsMZlM72Q4cFP4i2qkxHJa9QWv5MSQickd0JQovFUq7QP4uqo6m9PG\n\tIAWr7iyI0RKag==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1702651115;\n\tbh=H2afZgnbD7m3KtMjiKwtuIftrqoh7TPVfHzRErjOCXo=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=HL1JwAPxJ+X/sezdIWEaUlHd2Y5fet9HLFiVnl0CP2HI27iTVxfpJE3k7z9rKt92t\n\tYhh2UgtC7VDVYk0eSUer4tmb4Jc4r7gK0zCUXMZkbjIWrM03Xk0XHakM0m5j9fU0PO\n\tsyOXPMr3lext+uj1WKb3itgPWu+h6lWQfFAq0cfk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"HL1JwAPx\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<ZXiaHtJPfB/znr6p@duo.ucw.cz>","References":"<ZXiaHtJPfB/znr6p@duo.ucw.cz>","To":"Pavel Machek <pavel@ucw.cz>, libcamera-devel@lists.libcamera.org","Date":"Fri, 15 Dec 2023 14:39:18 +0000","Message-ID":"<170265115894.3044059.5110597091748483875@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] cam: Support RGB888 texture in sdl sink","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]