From patchwork Mon Aug 8 15:56:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17027 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 15BA5C3275 for ; Mon, 8 Aug 2022 15:56:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D2F4E6332E; Mon, 8 Aug 2022 17:56:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659974179; bh=8vwAW602/hcHJc5ZmZy+SX4BEfYiTdGy4GpFQeZR1mU=; 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=rFksmj2+769ryfs2rVndJuxw1v1puPusk9f9kNaEo2vEhfFOHlGztE2DJeVpSUyou 7gWFKGAzEqIWOiexjhXNiB/7eTjU/AZojel0Hy/ChIOIB4tvZYUDtPeEfRFJip5do+ 9+kmnCFyvCOmwhVr5BLmzOByblo1RkmdeejOKXeJcbI2mXdBgRCIMd0be9OaAhT6e9 mEf78V0Qu6ionHZSDgmXzEw8v+EC6zmT6WJM/BozdT62g/1DlGvlpIaeF7f47DIXOE N2QE0OyX4Q563gXXL25YwwpZ6FO6T7pg1lejzN5yzHFGn1/7rP+cQuii3rrnOoZDuz g2OMQNE2VVDDw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D80163327 for ; Mon, 8 Aug 2022 17:56:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="VGTvq/4s"; 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 B6F2E56D; Mon, 8 Aug 2022 17:56:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659974177; bh=8vwAW602/hcHJc5ZmZy+SX4BEfYiTdGy4GpFQeZR1mU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VGTvq/4selP0/LL7mQ4j4wTPFu5VSo1AeGjZ1HKi7d4rpHE6OZe0RWh2N3HDaWIyU Lmq1mdLB2/4caESdcvTcQZ3/1wcH58GfYdO8P0hmcx3Dq1JGpUVzSJ4o4uoq3VIZBa Dca00+5o/mSupCW2WdZ2lYejebF9Q7nZgXJ6bq4E= To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 18:56:04 +0300 Message-Id: <20220808155605.7925-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220808155605.7925-1-laurent.pinchart@ideasonboard.com> References: <20220808155605.7925-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] cam: sdl_sink: Fix compilation with SDL2 <2.0.16 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 SDL_UpdateNVTexture() function, used for NV12 texture support, has been introduced in SDL2 2.0.16. Compiling against older SDL versions fails with ../src/cam/sdl_texture_yuv.cpp: In member function ‘virtual void SDLTextureNV12::update(const std::vector >&)’: ../src/cam/sdl_texture_yuv.cpp:19:2: error: ‘SDL_UpdateNVTexture’ was not declared in this scope; did you mean ‘SDL_UpdateYUVTexture’? 19 | SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_, | ^~~~~~~~~~~~~~~~~~~ | SDL_UpdateYUVTexture Fix it with conditional compilation based on the SDL version. Fixes: 7b8df9fe6b3e ("cam: sdl_sink: Add NV12 texture support") Signed-off-by: Laurent Pinchart Reviewed-by: Eric Curtin --- src/cam/sdl_sink.cpp | 2 ++ src/cam/sdl_texture_yuv.cpp | 2 ++ src/cam/sdl_texture_yuv.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp index 5f2583721419..ee177227dbca 100644 --- a/src/cam/sdl_sink.cpp +++ b/src/cam/sdl_sink.cpp @@ -67,9 +67,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config) texture_ = std::make_unique(rect_); break; #endif +#if SDL_VERSION_ATLEAST(2, 0, 16) case libcamera::formats::NV12: texture_ = std::make_unique(rect_, cfg.stride); break; +#endif 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 431e836d2d2c..aa424559abd7 100644 --- a/src/cam/sdl_texture_yuv.cpp +++ b/src/cam/sdl_texture_yuv.cpp @@ -9,6 +9,7 @@ using namespace libcamera; +#if SDL_VERSION_ATLEAST(2, 0, 16) SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride) : SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride) { @@ -19,6 +20,7 @@ void SDLTextureNV12::update(const std::vector> &d SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_, data[1].data(), pitch_); } +#endif 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 633ab510259b..310e4e5046f4 100644 --- a/src/cam/sdl_texture_yuv.h +++ b/src/cam/sdl_texture_yuv.h @@ -9,12 +9,14 @@ #include "sdl_texture.h" +#if SDL_VERSION_ATLEAST(2, 0, 16) class SDLTextureNV12 : public SDLTexture { public: SDLTextureNV12(const SDL_Rect &rect, unsigned int stride); void update(const std::vector> &data) override; }; +#endif class SDLTextureYUYV : public SDLTexture {