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 { From patchwork Mon Aug 8 15:56:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 17028 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 8C88FBE173 for ; Mon, 8 Aug 2022 15:56:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4760B6332A; Mon, 8 Aug 2022 17:56:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659974182; bh=RYQV0ZR+VB1hu7gVwGg/nmZtPj/f88jVOm/xtfnqVAo=; 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=LYOISuwJDelABAKloE2TvOapCSClitHh1dllYOYr+x2igdlBlOftg+9XpxHwBgHfT 5s+nYrEaB//2WhmKmCo9jbkk1I9LwxXhCuaZa0EC7vwcw4FVjB1IeBnmuAGp/voeCn Q7zWrnJyiTKxLQGVga9BPvdAH+Qa8I3SMhr6430+dosHUqlupMI8fVCiDJ9PKD0tQt eCBCxGVjLVddIvz3Kb1CGhuedq48fy4ylG7u9ThNMTnNXn+jhomqVvziKrQZfmMbDQ UL3ytFk1ef9eIaDBz9fFf2oRnTNYkgbPmWZ4WxAp3tdeRF4ldC1I8SLDGROq2Mq/FS 7qMI2PRmw6vuQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1202663330 for ; Mon, 8 Aug 2022 17:56:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="WEkZbsmv"; 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 7676673E; Mon, 8 Aug 2022 17:56:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1659974179; bh=RYQV0ZR+VB1hu7gVwGg/nmZtPj/f88jVOm/xtfnqVAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WEkZbsmvtwfwwWUNSM+5qsiQ154iJoOWOsYCnAFOyV3tTutazPAKzXabyOC196VWV L/4Go92JXELAtN++BvtcsN8ZSGN11WBmSU34z/DvEbYSSxpa2YTjl5z2/FVpOb6j87 LhpS1mXbe3yez+adu6r12teg7v+y58C+79NP5slQ= To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Aug 2022 18:56:05 +0300 Message-Id: <20220808155605.7925-3-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 2/2] cam: sdl_texture: Renaming 'pitch' to 'stride' 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 libcamera public API uses 'stride' to refer to the line stride. Rename the SDLTexture::pitch_ member variable for consistency. Signed-off-by: Laurent Pinchart Reviewed-by: Eric Curtin Reviewed-by: Jacopo Mondi --- src/cam/sdl_texture.cpp | 4 ++-- src/cam/sdl_texture.h | 4 ++-- src/cam/sdl_texture_mjpg.cpp | 6 +++--- src/cam/sdl_texture_yuv.cpp | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cam/sdl_texture.cpp b/src/cam/sdl_texture.cpp index 02a8ff28b669..e9040bc5f67e 100644 --- a/src/cam/sdl_texture.cpp +++ b/src/cam/sdl_texture.cpp @@ -10,8 +10,8 @@ #include SDLTexture::SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, - const int pitch) - : ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), pitch_(pitch) + const int stride) + : ptr_(nullptr), rect_(rect), pixelFormat_(pixelFormat), stride_(stride) { } diff --git a/src/cam/sdl_texture.h b/src/cam/sdl_texture.h index e4d3fb2bcf39..6ccd85eab390 100644 --- a/src/cam/sdl_texture.h +++ b/src/cam/sdl_texture.h @@ -16,7 +16,7 @@ class SDLTexture { public: - SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int pitch); + SDLTexture(const SDL_Rect &rect, uint32_t pixelFormat, const int stride); virtual ~SDLTexture(); int create(SDL_Renderer *renderer); virtual void update(const std::vector> &data) = 0; @@ -26,5 +26,5 @@ protected: SDL_Texture *ptr_; const SDL_Rect rect_; const uint32_t pixelFormat_; - const int pitch_; + const int stride_; }; diff --git a/src/cam/sdl_texture_mjpg.cpp b/src/cam/sdl_texture_mjpg.cpp index 8dd5ee3eb6bc..da958e0372af 100644 --- a/src/cam/sdl_texture_mjpg.cpp +++ b/src/cam/sdl_texture_mjpg.cpp @@ -39,7 +39,7 @@ struct JpegErrorManager : public jpeg_error_mgr { SDLTextureMJPG::SDLTextureMJPG(const SDL_Rect &rect) : SDLTexture(rect, SDL_PIXELFORMAT_RGB24, rect.w * 3), - rgb_(std::make_unique(pitch_ * rect.h)) + rgb_(std::make_unique(stride_ * rect.h)) { } @@ -65,7 +65,7 @@ int SDLTextureMJPG::decompress(Span data) jpeg_start_decompress(&cinfo); for (int i = 0; cinfo.output_scanline < cinfo.output_height; ++i) { - JSAMPROW rowptr = rgb_.get() + i * pitch_; + JSAMPROW rowptr = rgb_.get() + i * stride_; jpeg_read_scanlines(&cinfo, &rowptr, 1); } @@ -79,5 +79,5 @@ int SDLTextureMJPG::decompress(Span data) void SDLTextureMJPG::update(const std::vector> &data) { decompress(data[0]); - SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), pitch_); + SDL_UpdateTexture(ptr_, nullptr, rgb_.get(), stride_); } diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp index aa424559abd7..b29c3b937265 100644 --- a/src/cam/sdl_texture_yuv.cpp +++ b/src/cam/sdl_texture_yuv.cpp @@ -17,8 +17,8 @@ SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride) void SDLTextureNV12::update(const std::vector> &data) { - SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_, - data[1].data(), pitch_); + SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), stride_, + data[1].data(), stride_); } #endif @@ -29,5 +29,5 @@ SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride) void SDLTextureYUYV::update(const std::vector> &data) { - SDL_UpdateTexture(ptr_, &rect_, data[0].data(), pitch_); + SDL_UpdateTexture(ptr_, &rect_, data[0].data(), stride_); }