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: