[{"id":24437,"web_url":"https://patchwork.libcamera.org/comment/24437/","msgid":"<CAOgh=Fyamsh+igmq00VBpRqCbkdKfZjYOmNQ0RZ97=wcezDo_g@mail.gmail.com>","date":"2022-08-08T19:21:59","subject":"Re: [libcamera-devel] [PATCH 1/2] cam: sdl_sink: Fix compilation\n\twith SDL2 <2.0.16","submitter":{"id":101,"url":"https://patchwork.libcamera.org/api/people/101/","name":"Eric Curtin","email":"ecurtin@redhat.com"},"content":"On Mon, 8 Aug 2022 at 16:56, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> The SDL_UpdateNVTexture() function, used for NV12 texture support, has\n> been introduced in SDL2 2.0.16. Compiling against older SDL versions\n> fails with\n>\n> ../src/cam/sdl_texture_yuv.cpp: In member function ‘virtual void SDLTextureNV12::update(const std::vector<libcamera::Span<const unsigned char> >&)’:\n> ../src/cam/sdl_texture_yuv.cpp:19:2: error: ‘SDL_UpdateNVTexture’ was not declared in this scope; did you mean ‘SDL_UpdateYUVTexture’?\n>    19 |  SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,\n>       |  ^~~~~~~~~~~~~~~~~~~\n>       |  SDL_UpdateYUVTexture\n>\n> Fix it with conditional compilation based on the SDL version.\n>\n> Fixes: 7b8df9fe6b3e (\"cam: sdl_sink: Add NV12 texture support\")\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nLGTM.\n\nReviewed-by: Eric Curtin <ecurtin@redhat.com>\n\n> ---\n>  src/cam/sdl_sink.cpp        | 2 ++\n>  src/cam/sdl_texture_yuv.cpp | 2 ++\n>  src/cam/sdl_texture_yuv.h   | 2 ++\n>  3 files changed, 6 insertions(+)\n>\n> diff --git a/src/cam/sdl_sink.cpp b/src/cam/sdl_sink.cpp\n> index 5f2583721419..ee177227dbca 100644\n> --- a/src/cam/sdl_sink.cpp\n> +++ b/src/cam/sdl_sink.cpp\n> @@ -67,9 +67,11 @@ int SDLSink::configure(const libcamera::CameraConfiguration &config)\n>                 texture_ = std::make_unique<SDLTextureMJPG>(rect_);\n>                 break;\n>  #endif\n> +#if SDL_VERSION_ATLEAST(2, 0, 16)\n>         case libcamera::formats::NV12:\n>                 texture_ = std::make_unique<SDLTextureNV12>(rect_, cfg.stride);\n>                 break;\n> +#endif\n>         case libcamera::formats::YUYV:\n>                 texture_ = std::make_unique<SDLTextureYUYV>(rect_, cfg.stride);\n>                 break;\n> diff --git a/src/cam/sdl_texture_yuv.cpp b/src/cam/sdl_texture_yuv.cpp\n> index 431e836d2d2c..aa424559abd7 100644\n> --- a/src/cam/sdl_texture_yuv.cpp\n> +++ b/src/cam/sdl_texture_yuv.cpp\n> @@ -9,6 +9,7 @@\n>\n>  using namespace libcamera;\n>\n> +#if SDL_VERSION_ATLEAST(2, 0, 16)\n>  SDLTextureNV12::SDLTextureNV12(const SDL_Rect &rect, unsigned int stride)\n>         : SDLTexture(rect, SDL_PIXELFORMAT_NV12, stride)\n>  {\n> @@ -19,6 +20,7 @@ void SDLTextureNV12::update(const std::vector<libcamera::Span<const uint8_t>> &d\n>         SDL_UpdateNVTexture(ptr_, &rect_, data[0].data(), pitch_,\n>                             data[1].data(), pitch_);\n>  }\n> +#endif\n>\n>  SDLTextureYUYV::SDLTextureYUYV(const SDL_Rect &rect, unsigned int stride)\n>         : SDLTexture(rect, SDL_PIXELFORMAT_YUY2, stride)\n> diff --git a/src/cam/sdl_texture_yuv.h b/src/cam/sdl_texture_yuv.h\n> index 633ab510259b..310e4e5046f4 100644\n> --- a/src/cam/sdl_texture_yuv.h\n> +++ b/src/cam/sdl_texture_yuv.h\n> @@ -9,12 +9,14 @@\n>\n>  #include \"sdl_texture.h\"\n>\n> +#if SDL_VERSION_ATLEAST(2, 0, 16)\n>  class SDLTextureNV12 : public SDLTexture\n>  {\n>  public:\n>         SDLTextureNV12(const SDL_Rect &rect, unsigned int stride);\n>         void update(const std::vector<libcamera::Span<const uint8_t>> &data) override;\n>  };\n> +#endif\n>\n>  class SDLTextureYUYV : public SDLTexture\n>  {\n> --\n> Regards,\n>\n> Laurent Pinchart\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id AE9C6C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Aug 2022 19:23:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 13E0563327;\n\tMon,  8 Aug 2022 21:23:17 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.129.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 617D563315\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Aug 2022 21:23:15 +0200 (CEST)","from mail-qt1-f199.google.com (mail-qt1-f199.google.com\n\t[209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n\tus-mta-99-wH9sTxaRMbGJoPRrE_iuaA-1; Mon, 08 Aug 2022 15:22:16 -0400","by mail-qt1-f199.google.com with SMTP id\n\tk3-20020ac86043000000b0033cab47c483so7436794qtm.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 08 Aug 2022 12:22:16 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1659986597;\n\tbh=pQIZITJjFJhWD4q0p1Vr8P/PF6e9XRRBCze3ils8r/I=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=V5Arc8QdaJ4Ndc2M3iUDBToqpHr1BGZNJSteKhj6QaPUL3/7I7unCj06+XNeCg6lc\n\t8xePKqk4GvMIfDg4BYE5kyGhq8PrdnB4e4PN//lT7TKdIkUjjtiKaP8hRc/gqfd5yo\n\t4bCmYz+C/p1xfrNV3ZEP0o9fOqHOYLWJwQrp109xNY4d+eS1mUCydzawTKCFHzjm4r\n\tHJQXrkleYghGKYKnloKQQw3riZ96tYHyHRZrTCVNQISw84nFgGQubx0iikS9ai75P7\n\tJJdiuUwsWblgcviAwRpJNX9C70r9wmlUfaKEUePkPZiFg9w3RYxXrF6mLjxP+W2Kt4\n\tNqkbS1YlDUjoQ==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1659986593;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=knyffOjieA2s5MY5i23jd8ADIs+c58l+LUY8teEEty8=;\n\tb=Lq79nTMLqwsapsTfrho/YcAmxfvoxeIGAfJAHaha5nJ1WaQHtokNnfW8l0T9ixsIlEJJnc\n\t9Iq31yY8ln6FS/WKeMICWUxfAqarqDNMNNmphUg2kQg5eQWBfgMfABk+udM1mtCF3T3aRr\n\tk8lsjYr5pOc3Xy2PkDMWiNIoOODx7SM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=redhat.com\n\theader.i=@redhat.com header.b=\"Lq79nTML\"; \n\tdkim-atps=neutral","X-MC-Unique":"wH9sTxaRMbGJoPRrE_iuaA-1","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc:content-transfer-encoding;\n\tbh=knyffOjieA2s5MY5i23jd8ADIs+c58l+LUY8teEEty8=;\n\tb=clGpycR8I1TtbU4CV/sXB1FskJTUiT6hqO1im5RqeGhw7ytFmyWLXs9+BZxX6xLafa\n\tHqTfTD/0Odzk/rCdZuB9jQJPGFlWP82VDxsnmfOzC3CI2Fq1UL7XBYjlr+fUSRkG9ugB\n\tDQEy5mCktOVByStHmowkR6ekH1/B1S2M7gFbRI4rGNyy+e3yLF8ZMRzZ3qEMHXszNwuH\n\t9KZ53ttrrxVnmHut4/3GNByG6YdFNGeqdEdKkDVU0SGPU8kdUXmik9D7em7581YB3xCa\n\t3pWx8oSYAe0xgrqpmtIdT7v4bCR6MMFbzZ2SspeE/xXOReV5ZGOHy9ZCGoFOAP7h14q7\n\twm/Q==","X-Gm-Message-State":"ACgBeo23a4Fxb9euVhZHt8ffoszatVOmDIKStzay5kKbiVUYxIWctcce\n\tRyosaRKulurtY40ZKQy4p60Xsp0qIVdlv1siOsm1Xw6N6Pkjr6AilFWNrGrvoBQ6wXWwR8kY/8B\n\traib7V7ADEDGBXEIPaJTEQ1YO4cyBmaduw3eSBMRGiksQh+bdDg==","X-Received":["by 2002:a05:620a:f10:b0:6aa:318e:55a9 with SMTP id\n\tv16-20020a05620a0f1000b006aa318e55a9mr14906334qkl.559.1659986536095; \n\tMon, 08 Aug 2022 12:22:16 -0700 (PDT)","by 2002:a05:620a:f10:b0:6aa:318e:55a9 with SMTP id\n\tv16-20020a05620a0f1000b006aa318e55a9mr14906312qkl.559.1659986535684;\n\tMon, 08 Aug 2022 12:22:15 -0700 (PDT)"],"X-Google-Smtp-Source":"AA6agR7DInf4kEiF0BOjnoW4A8JMcbRhDOEPWH025USaYUUhtCWdLZd5N9nk4JAMuJ45GFyp8iy64vFGYoAFyIlFEhM=","MIME-Version":"1.0","References":"<20220808155605.7925-1-laurent.pinchart@ideasonboard.com>\n\t<20220808155605.7925-2-laurent.pinchart@ideasonboard.com>","In-Reply-To":"<20220808155605.7925-2-laurent.pinchart@ideasonboard.com>","Date":"Mon, 8 Aug 2022 20:21:59 +0100","Message-ID":"<CAOgh=Fyamsh+igmq00VBpRqCbkdKfZjYOmNQ0RZ97=wcezDo_g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","X-Mimecast-Spam-Score":"0","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH 1/2] cam: sdl_sink: Fix compilation\n\twith SDL2 <2.0.16","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Eric Curtin via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Eric Curtin <ecurtin@redhat.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]