From patchwork Mon Feb 27 22:49:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suhrid Subramaniam X-Patchwork-Id: 18317 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 D1C29BE08A for ; Mon, 27 Feb 2023 22:50:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 97BFD6267E; Mon, 27 Feb 2023 23:50:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677538244; bh=OvFOgdhytnUxq9sLHEK9OxfYsVRB2KT92yJ8nZXUIQo=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=CXhxcOfn6Y/BQI9flxxyU8sMYsPLDcqhguAqZ0TaSS/pLV7bm5AtgYJj6Qb/k5hay DDAfT9zj+ISnBZEs/Aqegxf7C9BJCz0NvOPf/O8s+IczzS6mirF4X0lHR9qY3LrcC+ ttejm4F2Au7dFv7c+pu5uhtMkseRyPudqlvtSNJ+rZvoUJCU4IwADnOObcIxpH0IZQ Qw4O8O7TwiVur5BOaJ1UJ6cdTGF6BhwgbwAu2j9ab0NXM+t4Jaagu0DGvxdR0trHgz OK2E9xbRAi5yLjKIAcN5Fx3jlH7s9bzhYpigqBd0c4H4bFFWYl6HFf8Pr0WBTEXMYj 4M7gr2yr55AmA== Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 79A7662676 for ; Mon, 27 Feb 2023 23:50:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QnO/00Z1"; dkim-atps=neutral Received: by mail-pg1-x52d.google.com with SMTP id s17so4560246pgv.4 for ; Mon, 27 Feb 2023 14:50:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677538241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=55bXgzJ7lgqJoz6t2+4fIitcYoL4Exh0HE4g/IB3upo=; b=QnO/00Z1ePSztY6hLd8iGMp7Rcxeib5VN0p8rwsJqDVSx/xXcY06+hQ4sIjCOV3tU5 uaPtCnJwvWk3jg36mSCJfzwH7OO7cPfu5qTLJ3EsFsJBmInqqwT3gvXMLmW4rTqSbgq/ 3tyZXgx5s76twCc6RXGXkVj0naqEisfsoM6EwdCTT051hEGotwdSaSLbImwivBapraLy xv+FvV2pfyiU0GqAOwzSLcmMFuf4RRfLYjXZrt++CPLRYNKlJXg1odpMhGShyuAaY3HR /h0KxLphqgiVkUaJ1ZMP9OlHbqC906EOurgnyU9abkfq4iTCe/XD2+i9yFINQwfUmPQp mXaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677538241; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=55bXgzJ7lgqJoz6t2+4fIitcYoL4Exh0HE4g/IB3upo=; b=olq06BMy2TjJT2Ecwpd9IPlqvfJVpc+Bm7Bbgn09Fw57bpGCOMwZGjb3xE/WKhNQQW J0Wg0lsZlAAKD9qEclWg0ACf6AczFp8E9zZEf3DnQxp7CIzcSFe6jMIeir/kFoAkQTLX 0lqjQCnUCmhcsUACzCkovyq0nVbY6rbQdyHooZyxt2uZcyqYCfyuPn+f+Yh7aIFZ8ger 7Q36pjDCjd0iXzTYJ8cgInaGjbHqCXbzIIyzNvdWvUVibb0udMpKhD87BZbqbmALdb6M J+ZyvOmzHygnNsjK9g8Mh7Y86OnokkMLR9pSviTDE3pz+UxnUlh0++tB+dMIN2zo7+iP ubWw== X-Gm-Message-State: AO0yUKXGztkk9bOScp8GOFKzStSJmPQFmZe7oA/r40t1oh7NEUKS5syS 1LABaBO7dmDpQ+btSRmGvmYz8ddKuXsv4Q== X-Google-Smtp-Source: AK7set+SnyStz1lifNiTX2+mWzfIl/4PTC/trGhkUBiAcMC9UNlLvWGRX1ipzUsF2YwMGSQxqGPB7g== X-Received: by 2002:aa7:85d7:0:b0:5f5:313e:49dd with SMTP id z23-20020aa785d7000000b005f5313e49ddmr670766pfn.1.1677538240700; Mon, 27 Feb 2023 14:50:40 -0800 (PST) Received: from localhost.localdomain (sfosm0151r356001-v22.wiline.com. [67.207.106.98]) by smtp.gmail.com with ESMTPSA id 17-20020aa79111000000b005e00086250asm4663117pfh.125.2023.02.27.14.50.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:50:40 -0800 (PST) X-Google-Original-From: Suhrid Subramaniam To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Feb 2023 14:49:09 -0800 Message-Id: <20230227224910.151337-2-suhrid.subramaniam@mediatek.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230227224910.151337-1-suhrid.subramaniam@mediatek.com> References: <20230227224910.151337-1-suhrid.subramaniam@mediatek.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: pipeline: simple: Check converter_ 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: Suhrid Subramaniam via libcamera-devel From: Suhrid Subramaniam Reply-To: Suhrid Subramaniam Cc: Suhrid Subramaniam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" - If no converter is found, converter_ becomes a nullptr and !converter_->isValid() causes a segmentation fault. - Avoid this by checking if converter_ is a nullptr. Signed-off-by: Suhrid Subramaniam --- src/libcamera/pipeline/simple/simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 24ded4db..2423ec10 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -493,7 +493,7 @@ int SimpleCameraData::init() MediaDevice *converter = pipe->converter(); if (converter) { converter_ = ConverterFactoryBase::create(converter); - if (!converter_->isValid()) { + if (!converter_) { LOG(SimplePipeline, Warning) << "Failed to create converter, disabling format conversion"; converter_.reset(); From patchwork Mon Feb 27 22:49:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suhrid Subramaniam X-Patchwork-Id: 18318 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 9EC37C3257 for ; Mon, 27 Feb 2023 22:50:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2C50962694; Mon, 27 Feb 2023 23:50:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1677538246; bh=jaN+/nfcez7lJtFUSsvDq4Qe4wyry8QeqzQvJX6JMV4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ubCoTYpNqjC4txVPKmkati/yhqg7I55kX3hIho4e2yK5e5eI9+g6ff+jQ9viDZKyb tPlZfsSuQSt1r0SeduNFhQHa9FIYrlo9Cm7AwPTOtaTk7vN6c2zAK49FUD5GJ5crxN YQ1D1GVUhzzpIvVMF0NMKjkc5K+JIVhCNaC3/VtNBfVn3u3sRvzvH841OZTIHxOo5P dvU51o6wPY//S+yi0MQJyfYoPaHy6LrM3BU7dnkxApQRTpKdnJkNS3p8w6v2YgKlQI 3M6XuLJpopYBEgxnJEOzaJuQG8cBXIWxfaVYf6hmCNjCwt4I3VMRdbfM4qjA2QkKqc fNWCXPN46yEDw== Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D6F1E62690 for ; Mon, 27 Feb 2023 23:50:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="P5WaP6wn"; dkim-atps=neutral Received: by mail-pf1-x435.google.com with SMTP id n2so4551468pfo.12 for ; Mon, 27 Feb 2023 14:50:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TUwIo7V/DDZHADoaLqdJ9JLMhBpB5S/xmzbvJMLuhdc=; b=P5WaP6wn2Uo8eXemNUYiFIKL7Wsgsp5ZoWmqRxnI01mxZLPtSJfMealOjIS/7YUxC0 nzy8F7Uh0BQ3YJbs3dkLVamhyMKkBP0dUvO6D4fOP8pCm2Sna7vE2FWwPUTb/yv1N/lu IK9XBtLUWxa7bY/IzsGDgP3WDeiI/830weBPiIG3nKBbrQsth6DLlSXlzg6WvK3AyEE2 KyP8UNLq+w84yAxAkQ//ezoAjrXLD6fDCLkviFw51gDDYsKyOuh5MvqOmEv0kEHbKXsP X9Dnnb/UjSo4IwBF/Gbo5hNtnT305719lut6ywW8Nnr8QpDXccuUxZ7+CZwM/q+mwLgo 1Hkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TUwIo7V/DDZHADoaLqdJ9JLMhBpB5S/xmzbvJMLuhdc=; b=FqNX5x2k2dd9gSkcsK34Vk9sk4ounk3HLCa1oiPQCah1QLlj0uWKZvphbsP8+5VsrG WnQFxjzmMrlaCQroWyn9vc7jhDoS+qh+nDhrQbOTgefiYyUcXFDxXw0e2xyrFj4gd9Eg oIUN6pJqbVtLklecyoV9kQLQgSOHyyvRjzXjSGJYWJMVQ5XT6nYX/qFef/xHlR/FvVEB erzjxTJ0Skd2Or5NwTWF2Wwgham04q7Fydfn+TcC2K4B/0WYrvOh94npyZUWfogKoCI1 qiUySveIPbT7PYrGYDEuL2xbZyUBIkGR6zFqRY/jl6aSh1Xv+s7oxHiQlICT/tsri+h9 ZVyQ== X-Gm-Message-State: AO0yUKV9JKV2LUDBE2+cOd/AayLhfXTmEU0dw+8k0hza0YxhXnVW3n8a CX8oLBKJCTb9Aelys8kBMpYX+kQ+ohyocA== X-Google-Smtp-Source: AK7set9PK7hWKiaNryfwshNrXshsej1cAJgy7Yp3n2odsHYFzna8hsfXWu8aLC8Et9SRCEdYZzlPpA== X-Received: by 2002:a62:cdcc:0:b0:5e9:5b99:da9a with SMTP id o195-20020a62cdcc000000b005e95b99da9amr627409pfg.3.1677538243117; Mon, 27 Feb 2023 14:50:43 -0800 (PST) Received: from localhost.localdomain (sfosm0151r356001-v22.wiline.com. [67.207.106.98]) by smtp.gmail.com with ESMTPSA id 17-20020aa79111000000b005e00086250asm4663117pfh.125.2023.02.27.14.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:50:42 -0800 (PST) X-Google-Original-From: Suhrid Subramaniam To: libcamera-devel@lists.libcamera.org Date: Mon, 27 Feb 2023 14:49:10 -0800 Message-Id: <20230227224910.151337-3-suhrid.subramaniam@mediatek.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230227224910.151337-1-suhrid.subramaniam@mediatek.com> References: <20230227224910.151337-1-suhrid.subramaniam@mediatek.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] libcamera: pipeline: converter: return unique converter only if Valid 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: Suhrid Subramaniam via libcamera-devel From: Suhrid Subramaniam Reply-To: Suhrid Subramaniam Cc: Suhrid Subramaniam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" - Use isValid() to check if m2m_ exists for the selected converter_. - create an instance of the converter only if it is Valid. Signed-off-by: Suhrid Subramaniam --- src/libcamera/converter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcamera/converter.cpp b/src/libcamera/converter.cpp index 3de39cff..8a34d068 100644 --- a/src/libcamera/converter.cpp +++ b/src/libcamera/converter.cpp @@ -207,8 +207,9 @@ ConverterFactoryBase::ConverterFactoryBase(const std::string name, std::initiali * \param[in] media Name of the factory * * \return A unique pointer to a new instance of the converter subclass - * corresponding to the named factory or one of its alias. Otherwise a null - * pointer if no such factory exists + * corresponding to the named factory or one of its alias if the converter + * instance is valid (checked using isValid()). Otherwise a null pointer + * if no such factory exists */ std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) { @@ -227,7 +228,7 @@ std::unique_ptr ConverterFactoryBase::create(MediaDevice *media) << factory->name_ << " factory with " << (it == compatibles.end() ? "no" : media->driver()) << " alias."; - return factory->createInstance(media); + return factory->createInstance(media)->isValid() ? factory->createInstance(media) : nullptr; } return nullptr;