From patchwork Sun Aug 7 02:17:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17005 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 D95AEBE173 for ; Sun, 7 Aug 2022 02:17:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 514DB6332F; Sun, 7 Aug 2022 04:17:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659838650; bh=fMcU8iv+QcFfB6PnVplcf+n6XKNjTQQd6jhd4MaRAXI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WEH/uVeQL+EjgKuAadPLNpIw4jaqUCOX52QhDD0J22CfxjH8qHn8zBPlT9MEGQuHV tB8o9qL2JNFh2xCKrLGWgyLWo/weenHJsYlQ0sNL1AZ9/1AFX4nnFoB30zv3eE2WDw I6Q5ML+WFXoLZwqUQSacdrdnS3hPGm72TfOYHziX3lIkMzX0O4Cu9OfBLBO3eQS0mE QUjLTcu3tcg3+WGXKaHWt+nn6iru1R9qafs6xDO57t9D8xWe8Cbeqh5kQAPX8enGEZ xqiibrRrks8V7ghRFeE2RfpKaw9RKxzO32PP31Ft51LzLb6UDOoItA0pbiOlJoarUT HgQkdMjs0qgCA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 86E2263325 for ; Sun, 7 Aug 2022 04:17:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="BPdF4Y+s"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1E60E749; Sun, 7 Aug 2022 04:17:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659838648; bh=fMcU8iv+QcFfB6PnVplcf+n6XKNjTQQd6jhd4MaRAXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BPdF4Y+stEQuFV0TjyBP5dpjS3DuvniBE8APHGOhXHijBsFIzESuPOxtdk7MWovzs 2MjZ/r42sLuRCq1qZrzSfAwCjsWgxsa5P5yJcgQyr1rIKL+gW+b4JOZjG/2d/gbbIZ BPwDTF0ppefpl8a8LbR614cQyMrBYiOIKpSB35XY= To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 05:17:15 +0300 Message-Id: <20220807021718.9789-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> References: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] cam: sdl_texture_yuyv: Make line stride configurable 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The line stride of the texture is currently hardcoded based on the image width, which may not match the real stride. Use the stride value from the stream configuration instead. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin --- src/cam/sdl_sink.cpp | 2 +- src/cam/sdl_texture_yuyv.cpp | 4 ++-- src/cam/sdl_texture_yuyv.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index 19fdfd6dced5..a59d07519e1f 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -68,7 +68,7 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config) break; #endif case libcamera::formats::YUYV: - texture_ = std::make_unique(rect_); + texture_ = std::make_unique(rect_, cfg.stride); break; default: std::cerr << "Unsupported pixel format " diff --git a/src/cam/sdl_texture_yuyv.cpp b/src/cam/sdl_texture_yuyv.cpp index 637c0900edff..cb51fb0ef478 100644 --- a/src/cam/sdl_texture_yuyv.cpp +++ b/src/cam/sdl_texture_yuyv.cpp @@ -9,8 +9,8 @@ using namespace libcamera; -SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect) - : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, 4 * ((rect.w + 1) / 2)) +SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride) + : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride) { } diff --git a/src/cam/sdl_texture_yuyv.h b/src/cam/sdl_texture_yuyv.h index 529a72d6a40e..81e51381ec62 100644 --- a/src/cam/sdl_texture_yuyv.h +++ b/src/cam/sdl_texture_yuyv.h @@ -12,6 +12,6 @@ class SDLTextureYUYV : public SDLTexture { public: - SDLTextureYUYV(const SDL_Rect &rect); + SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride); void update(libcamera::Span data) override; }; From patchwork Sun Aug 7 02:17:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17006 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 36320C3275 for ; Sun, 7 Aug 2022 02:17:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E23A263334; Sun, 7 Aug 2022 04:17:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659838652; bh=WJlPPlPIFJcsv0qeU24ME+UUz6tQyxWZ4W6pr9pVbLQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=r9qQAx+EXOWwFlAXkhh+UkQPUPfMb9ulTLCu8au35JuNVeR+8DYeV8mQ1xkrZgyfI hFeNQZ3HgsOQqOpkN9fWK7MHlPg0H0FGK5wgls611Ou5smygCF8vsb9cl5bA5whUkh Vrl01geL3kJA/NUlDm4JpJv51QNBzwtJJ4IulxqjP/jM8Vm5ZQvT3LMJ6CEmpvBn/Q 4Q1BF19x2TXY6DhsmjoIW81oisJw+5rAgkrMep1vOu3TzH6MaeA5tLXfCPFrAnq7xK QbOljQ0ocDXwbE6K/giOXIJk5eSb7HclMf7YCEXEWugdNAnbgvdIo95H7HMXEg+uVi dJKWQtHiozZJA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E09BD6332E for ; Sun, 7 Aug 2022 04:17:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fslkkzpm"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4F41487A; Sun, 7 Aug 2022 04:17:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659838649; bh=WJlPPlPIFJcsv0qeU24ME+UUz6tQyxWZ4W6pr9pVbLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fslkkzpmAz+2LM5KiEW5LWPdatNCIrolI1/50AyBtelplP1YDR4EcnXb5Ngcrk6+l UOB5jAWy1QAeqdj7+c/oVYJrY5MpQgktOTEEleG4XkZICLZI0PtTJ430xmV5/n1135 SlWZxYfBMmWMldURxJV9C+Dxnbm9QbWs7Bz4bBKU= To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 05:17:16 +0300 Message-Id: <20220807021718.9789-3-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> References: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/4] cam: Rename sdl_texture_yuyv.{cpp, h} to sdl_texture_yuv.{cpp, h} 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In preparation for the addition of NV12 support in the SDL sink, rename the sdl_texture_yuyv.{cpp,h} files to just "yuv". Separate sdl_texture_nv12.{cpp,h} files could be added instead, but given how short the implementation will be, grouping all YUV formats in a single file is better. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin --- src/cam/meson.build | 2 +- src/cam/sdl_sink.cpp | 2 +- src/cam/{sdl_texture_yuyv.cpp => sdl_texture_yuv.cpp} | 4 ++-- src/cam/{sdl_texture_yuyv.h => sdl_texture_yuv.h} | 0 4 files changed, 4 insertions(+), 4 deletions(-) rename src/cam/{sdl_texture_yuyv.cpp => sdl_texture_yuv.cpp} (83%) rename src/cam/{sdl_texture_yuyv.h => sdl_texture_yuv.h} (100%) diff --git a/src/cam/meson.build b/src/cam/meson.build index 4dfa7b22aea9..8259239ff5a2 100644 --- a/src/cam/meson.build +++ b/src/cam/meson.build @@ -40,7 +40,7 @@ if libsdl2.found() cam_sources += files([ 'sdl_sink.cpp', 'sdl_texture.cpp', - 'sdl_texture_yuyv.cpp' + 'sdl_texture_yuv.cpp', ]) if libjpeg.found() diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index a59d07519e1f..04350bd5365b 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -24,7 +24,7 @@ #ifdef HAVE_LIBJPEG #include "sdl_texture_mjpg.h" #endif -#include "sdl_texture_yuyv.h" +#include "sdl_texture_yuv.h" using namespace libcamera; diff --git a/src/cam/sdl_texture_yuyv.cpp b/src/cam/sdl_texture_yuv.cpp similarity index 83% rename from src/cam/sdl_texture_yuyv.cpp rename to src/cam/sdl_texture_yuv.cpp index cb51fb0ef478..07df4961a1ab 100644 --- a/src/cam/sdl_texture_yuyv.cpp +++ b/src/cam/sdl_texture_yuv.cpp @@ -2,10 +2,10 @@ /* * Copyright (C) 2022, Ideas on Board Oy * - * sdl_texture_yuyv.cpp - SDL Texture YUYV + * sdl_texture_yuv.cpp - SDL Texture YUYV */ -#include "sdl_texture_yuyv.h" +#include "sdl_texture_yuv.h" using namespace libcamera; diff --git a/src/cam/sdl_texture_yuyv.h b/src/cam/sdl_texture_yuv.h similarity index 100% rename from src/cam/sdl_texture_yuyv.h rename to src/cam/sdl_texture_yuv.h From patchwork Sun Aug 7 02:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17007 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 C6181BE173 for ; Sun, 7 Aug 2022 02:17:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 54EAB63331; Sun, 7 Aug 2022 04:17:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659838653; bh=KywZ2FwG3Kb8AKYbTiz4EFReY9hHPxCG4Lx3eN52FWE=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WttK2fA6+W9EhC6tPfj82VrHE5Be27ZtK4+VY8MMB0++7oe9qMycxcID8cwBkyra8 R3HYKcdIJlYlR1ojpXDJgiaIaVJFCLY6Sx27tWc081TJLi0u4lmixO7+cVDH7skVmZ +L0dKEgqALCPZ901+0JXoNTpgnIGc25dOrrXn+3X7dGz8QvrwBQo//TTpQhX3zeUDF katgqKEJBnFbsQijn94pHUrAkNmvN2znITBoW75c0lDWhfmtz8Q5WKC4EqJiKf2Nj+ 5XTW92aP0t6H0zEGZQfhVTuUKELZuDs0B6qU94zsrRP6NjmNcWTEzu33kfnchaBjuf gDD+vh/UP6wNA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E76946332A for ; Sun, 7 Aug 2022 04:17:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KkKL70kG"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 83EDF896; Sun, 7 Aug 2022 04:17:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659838650; bh=KywZ2FwG3Kb8AKYbTiz4EFReY9hHPxCG4Lx3eN52FWE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KkKL70kGNNAPFHdniT18NyWo2w3h0MeU0/C0P3eMTt+tjtMXMtYAiEXGaEkPTxa+6 phHfSUF5tEIazg5EPowXFeL8kMZ93jC3X3SxXWMbP9ipIn2MJHByCYlHD49f2+NbbL cOPtJZrqGPfLB/WI1yn+OLlWr/mBLzKKbWQMatRE= To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 05:17:17 +0300 Message-Id: <20220807021718.9789-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> References: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/4] cam: sdl_sink: Support multi-planar formats 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In order to prepare for NV12 support, implement support for multi-planar formats in the SDL sink. This mainly consists in passing a vector of plane data to the SDLTexture::update() function instead of a single value. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin --- src/cam/sdl_sink.cpp | 21 +++++++++++++-------- src/cam/sdl_texture.h | 4 +++- src/cam/sdl_texture_mjpg.cpp | 4 ++-- src/cam/sdl_texture_mjpg.h | 2 +- src/cam/sdl_texture_yuv.cpp | 4 ++-- src/cam/sdl_texture_yuv.h | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index 04350bd5365b..9675cf275186 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -185,16 +185,21 @@ void SDLSink::renderBuffer(FrameBuffer *buffer) { Image *image = mappedBuffers_[buffer].get(); - /* \todo Implement support for multi-planar formats. */ - const FrameMetadata::Plane &meta = buffer->metadata().planes()[0]; + std::vector> planes; + unsigned int i = 0; - Span data = image->data(0); - if (meta.bytesused > data.size()) - std::cerr << "payload size " << meta.bytesused - << " larger than plane size " << data.size() - << std::endl; + for (const FrameMetadata::Plane &meta : buffer->metadata().planes()) { + Span data = image->data(i); + if (meta.bytesused > data.size()) + std::cerr << "payload size " << meta.bytesused + << " larger than plane size " << data.size() + << std::endl; - texture_->update(data); + planes.push_back(data); + i++; + } + + texture_->update(planes); SDL_RenderClear(renderer_); SDL_RenderCopy(renderer_, texture_->get(), nullptr, nullptr); diff --git a/src/cam/sdl_texture.h b/src/cam/sdl_texture.h index f523fa5ebf51..e4d3fb2bcf39 100644 --- a/src/cam/sdl_texture.h +++ b/src/cam/sdl_texture.h @@ -7,6 +7,8 @@ #pragma once +#include + #include #include "image.h" @@ -17,7 +19,7 @@ public: SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int pitch); virtual ~SDLTexture(); int create(SDL_Renderer *renderer); - virtual void update(libcamera::Span data) = 0; + virtual void update(const std::vector> &data) = 0; SDL_Texture *get() const { return ptr_; } protected: diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp index 7542efd75d96..8dd5ee3eb6bc 100644 --- a/src/cam/sdl_texture_mjpg.cpp +++ b/src/cam/sdl_texture_mjpg.cpp @@ -76,8 +76,8 @@ int SDLTextureMJPG::decompress(Span data) return 0; } -void SDLTextureMJPG::update(Span data) +void SDLTextureMJPG::update(const std::vector> &data) { - decompress(data); + decompress(data[0]); SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), pitch_); } diff --git a/src/cam/sdl_texture_mjpg.h b/src/cam/sdl_texture_mjpg.h index 5141ed73bf70..814ca79ac193 100644 --- a/src/cam/sdl_texture_mjpg.h +++ b/src/cam/sdl_texture_mjpg.h @@ -14,7 +14,7 @@ class SDLTextureMJPG : public SDLTexture public: SDLTextureMJPG(const SDL_Rect &rect); - void update(libcamera::Span data) override; + void update(const std::vector> &data) override; private: int decompress(libcamera::Span data); diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp index 07df4961a1ab..a5721182a68b 100644 --- a/src/cam/sdl_texture_yuv.cpp +++ b/src/cam/sdl_texture_yuv.cpp @@ -14,7 +14,7 @@ SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride) { } -void SDLTextureYUYV::update(Span data) +void SDLTextureYUYV::update(const std::vector> &data) { - SDL_UpdateTexture(ptr_, &rect_, data.data(), pitch_); + SDL_UpdateTexture(ptr_, &rect_, data[0].data(), pitch_); } diff --git a/src/cam/sdl_texture_yuv.h b/src/cam/sdl_texture_yuv.h index 81e51381ec62..c9130298b91d 100644 --- a/src/cam/sdl_texture_yuv.h +++ b/src/cam/sdl_texture_yuv.h @@ -13,5 +13,5 @@ class SDLTextureYUYV : public SDLTexture { public: SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride); - void update(libcamera::Span data) override; + void update(const std::vector> &data) override; }; From patchwork Sun Aug 7 02:17:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17008 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 998D6BE173 for ; Sun, 7 Aug 2022 02:17:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 55C026332E; Sun, 7 Aug 2022 04:17:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659838655; bh=t0x7iEmrjVYVZIpr1cK7XLRTsEHqHUuC03jI5hSuqco=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Y6eftFDCz3rmOWKMm5dZWmmj+NwSz9iKufsUDa/NwbVSzOadds0rqgXlfoM61N/0j 9issS2lmfoMGOB7ZGGK7EhQNMm2QyRDIZJ1AoJxTuwHVGlkmgMdtUP9yCyuk31xybv tqzWah4cSRIBGd3shlX1ouGXDkrCo9dKnvoWTkr3QIdK9vyspLuyJItWcNHLWchFZP oTk+KlWFpPRDIy/mcanhU64BtvQyXG5zf2sfCVieJEY/SvVbmzuCbR2ZusqDo4sz6o P9bfcvN+AH3ehGNGn3jIJwXXBXw2vTFgcvA/91KsByC388d/l8wO58Q3U0sq6G5PgF 1kvDYB7JqL/uA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 20BA663331 for ; Sun, 7 Aug 2022 04:17:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rHdNUG7l"; dkim-atps=neutral Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AB4A2749; Sun, 7 Aug 2022 04:17:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659838651; bh=t0x7iEmrjVYVZIpr1cK7XLRTsEHqHUuC03jI5hSuqco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rHdNUG7lg6L+haxzT4ls6jZagOwtNRIEvugm9HKJnQQdwYs+pFuLYasiS8z0KCnCl qrp16txMq7Eu1ORgDpphb+Vvne9WPnSQOEbpgkEwodYq/OKO2KCZ5wjlkWWgFHCAJM 94ye89M3IC98jmCCyKHv66EPhNGNXcRx/6/jxOaE= To: libcamera-devel@lists.libcamera.org Date: Sun, 7 Aug 2022 05:17:18 +0300 Message-Id: <20220807021718.9789-5-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> References: <20220807021718.9789-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/4] cam: sdl_sink: Add NV12 texture support 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: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend the SDL sink with support for NV12 textures, useful on platforms that don't support packed YUYV formats. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin --- src/cam/sdl_sink.cpp | 3 +++ src/cam/sdl_texture_yuv.cpp | 13 ++++++++++++- src/cam/sdl_texture_yuv.h | 9 ++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index 9675cf275186..23fe2b1e9f05 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -67,6 +67,9 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config) texture_ = std::make_unique(rect_); break; #endif + case libcamera::formats::NV12: + texture_ = std::make_unique(rect_, cfg.stride); + break; case libcamera::formats::YUYV: texture_ = std::make_unique(rect_, cfg.stride); break; diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp index a5721182a68b..431e836d2d2c 100644 --- a/src/cam/sdl_texture_yuv.cpp +++ b/src/cam/sdl_texture_yuv.cpp @@ -2,13 +2,24 @@ /* * Copyright (C) 2022, Ideas on Board Oy * - * sdl_texture_yuv.cpp - SDL Texture YUYV + * sdl_texture_yuv.cpp - SDL YUV Textures */ #include "sdl_texture_yuv.h" using namespace libcamera; +SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride) + : SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride) +{ +} + +void SDLTextureNV12::update(const std::vector> &data) +{ + SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_, + data[1].data(), pitch_); +} + SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride) : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride) { diff --git a/src/cam/sdl_texture_yuv.h b/src/cam/sdl_texture_yuv.h index c9130298b91d..9da611fe0e36 100644 --- a/src/cam/sdl_texture_yuv.h +++ b/src/cam/sdl_texture_yuv.h @@ -2,13 +2,20 @@ /* * Copyright (C) 2022, Ideas on Board Oy * - * sdl_texture_yuyv.h - SDL Texture YUYV + * sdl_texture_yuyv.h - SDL YUV Textures */ #pragma once #include "sdl_texture.h" +class SDLTextureNV12 : public SDLTexture +{ +public: + SDLTextureNV12(const SDL_Rect &rect, unsigned int stride); + void update(const std::vector> &data) override; +}; + class SDLTextureYUYV : public SDLTexture { public: