From patchwork Wed Dec 6 11:00:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 19287 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 09AACC31E9 for ; Wed, 6 Dec 2023 11:00:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 893F8629E3; Wed, 6 Dec 2023 12:00:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701860430; bh=wVkycnv0JFtioU+Cd7OOHSlWcuPvOP8ZRanW7HqXz/s=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Qe1mCFpjKRuKiDZ68GJf2RkcoeSvhK+ZPCRrMFyiOqj5x0uAIHwuY/0SG73zg4Cvo 6cOD7hqnq2darqitAif9XX0K7AeqCeQ1Ii94ilh5poYh78nlAR58KLdUMEkibTLYWn GmN5IUWM5YB8d4oGx1vjyFr+OjYpm4pLc0B+c8uNM8fPxZtcwcRa1PhaLPpTuN6Mnz HtBkxdyBxRDY9ikXG5IGzvsbSYuVQOT/FS6v0leTvwUbyFys5OIFdVRSZTQU41gIiC 7U8sH+0B5iZmCKW6w8C0MKWWPu2xTWMVv1OeXgTnXQoCivodirdds8v1ngoEmdkTsn ZPE+QAeRoZL1w== Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DBD9F629CD for ; Wed, 6 Dec 2023 12:00:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ucw.cz header.i=@ucw.cz header.b="FlMFl1+y"; dkim-atps=neutral Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 70B231C0075; Wed, 6 Dec 2023 12:00:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1701860428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=nttk44eJlVAWuou3k4bpxdjkAwq/MydmUcrGojpnnO0=; b=FlMFl1+ys62C4j3lt2TvQ+CjDKylVVRk3Ww6VSfHVdkbt47esORPioYeNFT07yG+ljv5sy WwzuBV6mP5bMx3lEWZNk4zhyL1aQy+UeT95tLGhDDBT2VlGt50A42DylUF9ovPMg73vrjB o9XTMYpY0Xb5rGmSQ7uWPFlTebI4+Ns= Date: Wed, 6 Dec 2023 12:00:27 +0100 To: libcamera-devel@lists.libcamera.org Message-ID: MIME-Version: 1.0 Content-Disposition: inline Subject: [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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pavel Machek via libcamera-devel From: Pavel Machek Reply-To: Pavel Machek Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Lightly tested; this is useful for SoftISP testing. I get wrong red/blue swapped, but that may be due to my SoftISP hacks. Signed-off-by: Pavel Machek diff --git a/src/apps/cam/sdl_sink.cpp b/src/apps/cam/sdl_sink.cpp index a2f4abc1..105fa781 100644 --- a/src/apps/cam/sdl_sink.cpp +++ b/src/apps/cam/sdl_sink.cpp @@ -76,6 +76,9 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config) case libcamera::formats::YUYV: texture_ = std::make_unique(rect_, cfg.stride); break; + case libcamera::formats::RGB888: + texture_ = std::make_unique(rect_, cfg.stride); + break; default: std::cerr << "Unsupported pixel format " << cfg.pixelFormat.toString() << std::endl; diff --git a/src/apps/cam/sdl_texture_yuv.cpp b/src/apps/cam/sdl_texture_yuv.cpp index b29c3b93..c4c4144b 100644 --- a/src/apps/cam/sdl_texture_yuv.cpp +++ b/src/apps/cam/sdl_texture_yuv.cpp @@ -31,3 +31,13 @@ void SDLTextureYUYV::update(const std::vector> &d { SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_); } + +SDLTextureRGB888::SDLTextureRGB888(const SDL_Rect &rect, unsigned int stride) + : SDLTexture(rect, SDL_PIXELFORMAT_RGB24, stride) +{ +} + +void SDLTextureRGB888::update(const std::vector> &data) +{ + SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_); +} diff --git a/src/apps/cam/sdl_texture_yuv.h b/src/apps/cam/sdl_texture_yuv.h index 310e4e50..0df6b445 100644 --- a/src/apps/cam/sdl_texture_yuv.h +++ b/src/apps/cam/sdl_texture_yuv.h @@ -24,3 +24,10 @@ public: SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride); void update(const std::vector> &data) override; }; + +class SDLTextureRGB888 : public SDLTexture +{ +public: + SDLTextureRGB888(const SDL_Rect &rect, unsigned int stride); + void update(const std::vector> &data) override; +};