Show a patch.

GET /api/patches/14067/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 14067,
    "url": "https://patchwork.libcamera.org/api/patches/14067/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/14067/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20211007072147.1289490-1-hanlinchen@chromium.org>",
    "date": "2021-10-07T07:21:45",
    "name": "[libcamera-devel,v2,1/3] ipu3: Remove the usage of SharedItemPool",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "b36e3305a6dfa0d48d038cc16b0c3e1caf5c71cb",
    "submitter": {
        "id": 98,
        "url": "https://patchwork.libcamera.org/api/people/98/?format=api",
        "name": "Hanlin Chen",
        "email": "hanlinchen@chromium.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/14067/mbox/",
    "series": [
        {
            "id": 2606,
            "url": "https://patchwork.libcamera.org/api/series/2606/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2606",
            "date": "2021-10-07T07:21:45",
            "name": "[libcamera-devel,v2,1/3] ipu3: Remove the usage of SharedItemPool",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2606/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/14067/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/14067/checks/",
    "tags": {},
    "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 937DCC323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Oct 2021 07:22:14 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5F940691BA;\n\tThu,  7 Oct 2021 09:22:14 +0200 (CEST)",
            "from mail-pg1-x531.google.com (mail-pg1-x531.google.com\n\t[IPv6:2607:f8b0:4864:20::531])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 61C9C69189\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Oct 2021 09:22:12 +0200 (CEST)",
            "by mail-pg1-x531.google.com with SMTP id r2so4821475pgl.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 07 Oct 2021 00:22:12 -0700 (PDT)",
            "from localhost ([2401:fa00:1:10:db0a:f55:d7cb:95ae])\n\tby smtp.gmail.com with UTF8SMTPSA id\n\tx193sm12148156pfd.57.2021.10.07.00.22.09\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 07 Oct 2021 00:22:10 -0700 (PDT)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"DdVJjtZy\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=mqoroVLP45q/3Elje5qFmKzQRIGkFEMA0ANJVAprPW0=;\n\tb=DdVJjtZy6kF1fcXDmtaHC5d+b4u9UqTssT09MNz3FqZzbvcheX5LLQdRMpFTnpaV84\n\tCVo2xIs1eNJoqtByOGT9JbHPJXmJJ29FYWlEB61+XH64K3+ELWvJIiR6YGCo1tzFqTNJ\n\tWFZuE1/UlDyWc5dWw9GjNXq+xSJ8WAWTBqONU=",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=mqoroVLP45q/3Elje5qFmKzQRIGkFEMA0ANJVAprPW0=;\n\tb=00BdLGmk6yH1/jW56v/FCya7w/fTtQHEya36FCzxId7cExGIGZPV6rQKAvGzuAADEg\n\tTSAbYK2IROV428dpFUVQ1t/IuD4aAdeiIxUta85N+LgGpHkiFSsKjTfD87RqHjtfrL6O\n\tLRlRKs7klGLW6GvZMwy5UdLTzEcfUlH7Mp5Yha20g3EDdj2cqxfkrR9hX4OsLUz6XvRa\n\t8qDMEF0afBKBqFKyRSuPAj2eHRwRWcmgpP/BrnYkye5+z07I0Oa8TxOITXKEx3rXQZZC\n\tDHqnlnrM07z6Ysw5LaE8SpoCey1UbmgLp92HwBOGXCuQ+NbgRjSut/nn7V1fUcELa3S3\n\t4Wtw==",
        "X-Gm-Message-State": "AOAM532+aBBrELXCxSgV1hdautuXSy6GROpzXAemvfZbsmHJLe8kn+Jo\n\tU3tGecmIxhTsoTI/2N/E/slxyhcw3BWMdEVuFxQ=",
        "X-Google-Smtp-Source": "ABdhPJyFSs9+ovFAMtOvAY/ra530X/XtNHOYq5xiTEufXs0nkSE0+8nv/Yntl05B8Ydlh6qjVi1CTw==",
        "X-Received": "by 2002:a63:df16:: with SMTP id\n\tu22mr2124239pgg.150.1633591330269; \n\tThu, 07 Oct 2021 00:22:10 -0700 (PDT)",
        "From": "Han-Lin Chen <hanlinchen@chromium.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  7 Oct 2021 15:21:45 +0800",
        "Message-Id": "<20211007072147.1289490-1-hanlinchen@chromium.org>",
        "X-Mailer": "git-send-email 2.33.0.882.g93a45727a2-goog",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 1/3] ipu3: Remove the usage of\n\tSharedItemPool",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "The SharedItemPool was migrated from Chrome OS to maintain RGBS and AF\ngrids in IPAIPU3Stats. The orginal reason is to reserve the validness\nunitl the grids are processed in a different thread. However, it leads\nto a subtle bug which recycles the buffer before sending into AIQ\nlibraries. Since the IPU3 IPA (Unlike Chrome OS) process IPAIPU3Stats\nin a single thread, It would be simpler to maintain the grids as the\nmembers of IPAIPU3Stats, and remove the usage of SharedItemPool.\n\nSigned-off-by: Han-Lin Chen <hanlinchen@chromium.org>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n stats/ipa_ipu3_stats.cpp   | 145 ++++++-------------------------------\n stats/ipa_ipu3_stats.h     |  41 +++++++----\n stats/meson.build          |   1 -\n stats/shared_item_pool.cpp | 129 ---------------------------------\n stats/shared_item_pool.h   | 114 -----------------------------\n 5 files changed, 47 insertions(+), 383 deletions(-)\n delete mode 100644 stats/shared_item_pool.cpp\n delete mode 100644 stats/shared_item_pool.h",
    "diff": "diff --git a/stats/ipa_ipu3_stats.cpp b/stats/ipa_ipu3_stats.cpp\nindex c14bd7e..6697c9b 100644\n--- a/stats/ipa_ipu3_stats.cpp\n+++ b/stats/ipa_ipu3_stats.cpp\n@@ -15,30 +15,22 @@ namespace libcamera::ipa::ipu3 {\n \n LOG_DEFINE_CATEGORY(IPAIPU3Stats)\n \n-IPAIPU3Stats::IPAIPU3Stats()\n-{\n-\taiqStatsInputParams_ = {};\n-\n-\t/* \\todo: Is this fine here or we need separate helper? */\n-\trgbsGridBuffPool_ = std::make_shared<SharedItemPool<ia_aiq_rgbs_grid>>(\"RgbsGridBuffPool\");\n-\tafFilterBuffPool_ = std::make_shared<SharedItemPool<ia_aiq_af_grid>>(\"AfFilterBuffPool\");\n-#define PUBLIC_STATS_POOL_SIZE 9 /* comes from CrOS */\n-\tint ret = allocateStatBufferPools(PUBLIC_STATS_POOL_SIZE);\n-\tif (ret < 0)\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to allocate stats grid buffers\";\n-}\n-\n-IPAIPU3Stats::~IPAIPU3Stats()\n-{\n-\tfreeStatBufferPools();\n-\trgbsGridBuffPool_.reset();\n-\tafFilterBuffPool_.reset();\n-}\n-\n ia_aiq_statistics_input_params *\n IPAIPU3Stats::getInputStatsParams(int frame, aiq::AiqResults *results,\n \t\t\t\t  const ipu3_uapi_stats_3a *stats)\n {\n+\tIPU3AllStats::ipu3_stats_all_stats outStats = {};\n+\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\n+\n+\trgbsGrid_.blocks_ptr = rgbsGridBlock_;\n+\n+\tafGrid_.filter_response_1 = filterResponse1_;\n+\tafGrid_.filter_response_2 = filterResponse2_;\n+\n+\tIPU3AllStats::intel_skycam_statistics_convert(\n+\t\t\toutStats.ia_css_4a_statistics, &rgbsGrid_, &afGrid_);\n+\n+\taiqStatsInputParams_ = {};\n \taiqStatsInputParams_.frame_id = frame;\n \taiqStatsInputParams_.frame_ae_parameters = results->ae();\n \taiqStatsInputParams_.frame_af_parameters = results->af();\n@@ -47,117 +39,24 @@ IPAIPU3Stats::getInputStatsParams(int frame, aiq::AiqResults *results,\n \taiqStatsInputParams_.frame_sa_parameters = results->sa();\n \taiqStatsInputParams_.camera_orientation = ia_aiq_camera_orientation_unknown;\n \n-\tIPU3AllStats::ipu3_stats_all_stats outStats;\n-\tmemset(&outStats, 0, sizeof(IPU3AllStats::ipu3_stats_all_stats));\n-\tIPU3AllStats::ipu3_stats_get_3a(&outStats, stats);\n-\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n-\tint ret = afFilterBuffPool_->acquireItem(afGrid);\n-\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\n-\tif (ret != 0 || afGrid.get() == nullptr || rgbsGrid.get() == nullptr) {\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire 3A buffers from pools\";\n-\t\treturn nullptr;\n-\t}\n-\n-\tIPU3AllStats::intel_skycam_statistics_convert(outStats.ia_css_4a_statistics,\n-\t\t\t\t\t\t      rgbsGrid.get(), afGrid.get());\n-\n-\tconst ia_aiq_rgbs_grid *rgbsGridPtr = rgbsGrid.get();\n-\tconst ia_aiq_af_grid *afGridPtr = afGrid.get();\n-\n+\trgbsGridPtr_ = &rgbsGrid_;\n \taiqStatsInputParams_.num_rgbs_grids = 1;\n-\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr;\n+\taiqStatsInputParams_.rgbs_grids = &rgbsGridPtr_;\n+\n+\tafGridPtr_ = &afGrid_;\n \taiqStatsInputParams_.num_af_grids = 1;\n-\taiqStatsInputParams_.af_grids = &afGridPtr;\n+\taiqStatsInputParams_.af_grids = &afGridPtr_;\n \n \taiqStatsInputParams_.hdr_rgbs_grid = nullptr;\n \taiqStatsInputParams_.depth_grids = nullptr;\n \n-\treturn &aiqStatsInputParams_;\n-}\n+\taiqStatsInputParams_.num_external_histograms = 0;\n+\taiqStatsInputParams_.external_histograms = nullptr;\n \n-int IPAIPU3Stats::allocateStatBufferPools(int numBufs)\n-{\n-\tint ret = afFilterBuffPool_->init(numBufs);\n-\tret |= rgbsGridBuffPool_->init(numBufs);\n-\tif (ret != 0) {\n-\t\tLOG(IPAIPU3Stats, Error) << \"Failed to initialize 3A statistics pools\";\n-\t\tfreeStatBufferPools();\n-\t\treturn -ENOMEM;\n-\t}\n-#define IPU3_MAX_STATISTICS_WIDTH 80\n-#define IPU3_MAX_STATISTICS_HEIGHT 60\n-\tint maxGridSize = IPU3_MAX_STATISTICS_WIDTH * IPU3_MAX_STATISTICS_HEIGHT;\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n-\n-\tfor (int allocated = 0; allocated < numBufs; allocated++) {\n-\t\tret = afFilterBuffPool_->acquireItem(afGrid);\n-\t\tret |= rgbsGridBuffPool_->acquireItem(rgbsGrid);\n-\n-\t\tif (ret != 0 || afGrid.get() == nullptr ||\n-\t\t    rgbsGrid.get() == nullptr) {\n-\t\t\tLOG(IPAIPU3Stats, Error) << \"Failed to acquire memory from pools\";\n-\t\t\tfreeStatBufferPools();\n-\t\t\treturn -ENOMEM;\n-\t\t}\n-\n-\t\trgbsGrid->blocks_ptr = new rgbs_grid_block[maxGridSize];\n-\t\trgbsGrid->grid_height = 0;\n-\t\trgbsGrid->grid_width = 0;\n-\n-\t\tafGrid->filter_response_1 = new int[maxGridSize];\n-\t\tafGrid->filter_response_2 = new int[maxGridSize];\n-\t\tafGrid->block_height = 0;\n-\t\tafGrid->block_width = 0;\n-\t\tafGrid->grid_height = 0;\n-\t\tafGrid->grid_width = 0;\n-\t}\n-\n-\treturn 0;\n-}\n+\t/* \\todo: Fill the face state after the integration of face detection. */\n+\taiqStatsInputParams_.faces = nullptr;\n \n-void IPAIPU3Stats::freeStatBufferPools()\n-{\n-\tif (!afFilterBuffPool_->isFull() || !rgbsGridBuffPool_->isFull()) {\n-\t\t/* We will leak if we errored out in allocateStatBufferPools*/\n-\t\tif (!afFilterBuffPool_->isFull())\n-\t\t\tLOG(IPAIPU3Stats, Warning) << \"AfFilterBuffPool is leaking\";\n-\t\tif (!rgbsGridBuffPool_->isFull())\n-\t\t\tLOG(IPAIPU3Stats, Warning) << \"RgbsGridBuffPool is leaking\";\n-\t}\n-\n-\tint ret;\n-\tsize_t availableItems = afFilterBuffPool_->availableItems();\n-\tstd::shared_ptr<ia_aiq_af_grid> afGrid = nullptr;\n-\tfor (size_t i = 0; i < availableItems; i++) {\n-\t\tret = afFilterBuffPool_->acquireItem(afGrid);\n-\t\tif (ret == 0 && afGrid.get() != nullptr) {\n-\t\t\tdelete[] afGrid->filter_response_1;\n-\t\t\tafGrid->filter_response_1 = nullptr;\n-\t\t\tdelete[] afGrid->filter_response_2;\n-\t\t\tafGrid->filter_response_2 = nullptr;\n-\t\t} else {\n-\t\t\tLOG(IPAIPU3Stats, Warning)\n-\t\t\t\t<< \"Could not acquire AF filter response \"\n-\t\t\t\t<< i << \"for deletion - leak?\";\n-\t\t}\n-\t}\n-\n-\tavailableItems = rgbsGridBuffPool_->availableItems();\n-\tstd::shared_ptr<ia_aiq_rgbs_grid> rgbsGrid = nullptr;\n-\tfor (size_t i = 0; i < availableItems; i++) {\n-\t\tret = rgbsGridBuffPool_->acquireItem(rgbsGrid);\n-\t\tif (ret == 0 && rgbsGrid.get() != nullptr) {\n-\t\t\tdelete[] rgbsGrid->blocks_ptr;\n-\t\t\trgbsGrid->blocks_ptr = nullptr;\n-\t\t} else {\n-\t\t\tLOG(IPAIPU3Stats, Warning)\n-\t\t\t\t<< \"Could not acquire RGBS grid \" << i\n-\t\t\t\t<< \"for deletion - leak?\";\n-\t\t}\n-\t}\n+\treturn &aiqStatsInputParams_;\n }\n \n } /* namespace libcamera::ipa::ipu3 */\ndiff --git a/stats/ipa_ipu3_stats.h b/stats/ipa_ipu3_stats.h\nindex 4320024..5f59558 100644\n--- a/stats/ipa_ipu3_stats.h\n+++ b/stats/ipa_ipu3_stats.h\n@@ -5,38 +5,47 @@\n  * IPAIPU3Stats.cpp: Generate statistics in IA AIQ consumable format.\n  */\n \n-#include \"aiq/aiq_results.h\"\n-\n #ifndef IPA_IPU3_STATS_H\n #define IPA_IPU3_STATS_H\n \n-#include <ia_imaging/ia_aiq_types.h>\n #include <linux/intel-ipu3.h>\n-\n-#include \"shared_item_pool.h\"\n+#include \"aiq/aiq_results.h\"\n \n namespace libcamera::ipa::ipu3 {\n \n+constexpr uint32_t IPU3MaxStatisticsWidth = 80;\n+constexpr uint32_t IPU3MaxStatisticsHeight = 60;\n+constexpr uint32_t IPU3MaxStatisticsGridSize =\n+\tIPU3MaxStatisticsWidth * IPU3MaxStatisticsHeight;\n+\n struct AiqResults;\n \n class IPAIPU3Stats\n {\n public:\n-\tIPAIPU3Stats();\n-\t~IPAIPU3Stats();\n+\tIPAIPU3Stats() = default;\n+\t~IPAIPU3Stats() = default;\n \n-\tia_aiq_statistics_input_params *\n-\tgetInputStatsParams(int frame,\n-\t\t\t    aiq::AiqResults *results,\n-\t\t\t    const ipu3_uapi_stats_3a *stats);\n+\tia_aiq_statistics_input_params* getInputStatsParams(\n+\t\t\tint frame,\n+\t\t\taiq::AiqResults *results,\n+\t\t\tconst ipu3_uapi_stats_3a *stats);\n \n private:\n-\tvoid freeStatBufferPools();\n-\tint allocateStatBufferPools(int numBufs);\n+\tia_aiq_statistics_input_params aiqStatsInputParams_ = {};\n+\n+\t/*!< ia_aiq_statistics_input_params pointer contents */\n+\tconst ia_aiq_rgbs_grid* rgbsGridPtr_ = nullptr;\n+\tconst ia_aiq_af_grid* afGridPtr_ = nullptr;\n+\tia_aiq_rgbs_grid rgbsGrid_ = {};\n+\tia_aiq_af_grid afGrid_ = {};\n+\n+\t/*!< ia_aiq_rgbs_grid pointer contents */\n+\trgbs_grid_block rgbsGridBlock_[IPU3MaxStatisticsGridSize] = {};\n \n-\tia_aiq_statistics_input_params aiqStatsInputParams_;\n-\tstd::shared_ptr<SharedItemPool<ia_aiq_af_grid>> afFilterBuffPool_;\n-\tstd::shared_ptr<SharedItemPool<ia_aiq_rgbs_grid>> rgbsGridBuffPool_;\n+\t/*!< ia_aiq_af_grid pointer contents */\n+\tint filterResponse1_[IPU3MaxStatisticsGridSize] = {};\n+\tint filterResponse2_[IPU3MaxStatisticsGridSize] = {};\n };\n \n } /* namespace libcamera::ipa::ipu3 */\ndiff --git a/stats/meson.build b/stats/meson.build\nindex 74ce657..e28a6b9 100644\n--- a/stats/meson.build\n+++ b/stats/meson.build\n@@ -3,6 +3,5 @@\n ipu3_ipa_files += files([\n     'ipa_ipu3_stats.cpp',\n     'ipu3_all_stats.cpp',\n-    'shared_item_pool.cpp',\n ])\n \ndiff --git a/stats/shared_item_pool.cpp b/stats/shared_item_pool.cpp\ndeleted file mode 100644\nindex 326a400..0000000\n--- a/stats/shared_item_pool.cpp\n+++ /dev/null\n@@ -1,129 +0,0 @@\n-/* SPDX-License-Identifier: Apache-2.0 */\n-/*\n- * Copyright (C) 2014-2018 Intel Corporation\n- *\n- * This implementation is highly derived from ChromeOS:\n- *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.cpp\n- */\n-\n-#include <ia_imaging/ia_aiq_types.h>\n-\n-#include <libcamera/base/log.h>\n-\n-#include \"shared_item_pool.h\"\n-\n-namespace libcamera {\n-\n-LOG_DEFINE_CATEGORY(SharedItemPool)\n-\n-template<class ItemType>\n-SharedItemPool<ItemType>::SharedItemPool(const char *name)\n-\t: allocated_(nullptr), capacity_(0), deleter_(this), poolName_(name),\n-\t  resetter_(nullptr)\n-{\n-}\n-\n-template<class ItemType>\n-SharedItemPool<ItemType>::~SharedItemPool()\n-{\n-\tdeInit();\n-}\n-\n-template<class ItemType>\n-int SharedItemPool<ItemType>::init(int32_t capacity, void (*resetter)(ItemType *))\n-{\n-\tif (capacity_ != 0) {\n-\t\tLOG(SharedItemPool, Error) << \"Pool initialized already\";\n-\t\treturn -ENOSYS;\n-\t}\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tresetter_ = resetter;\n-\tcapacity_ = capacity;\n-\tavailable_.reserve(capacity);\n-\tallocated_ = new ItemType[capacity];\n-\n-\tfor (int32_t i = 0; i < capacity; i++)\n-\t\tavailable_.push_back(&allocated_[i]);\n-\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_ << \"init with \" << capacity << \" items\";\n-\n-\treturn 0;\n-}\n-\n-template<class ItemType>\n-bool SharedItemPool<ItemType>::isFull()\n-{\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tbool ret = (available_.size() == capacity_);\n-\treturn ret;\n-}\n-\n-template<class ItemType>\n-int SharedItemPool<ItemType>::deInit()\n-{\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tif (capacity_ == 0) {\n-\t\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n-\t\t\t\t\t   << \" isn't initialized or already de-initialized\";\n-\t\treturn 0;\n-\t}\n-\tif (available_.size() != capacity_) {\n-\t\tLOG(SharedItemPool, Error) << \"Not all items are returned \"\n-\t\t\t\t\t   << \"when destroying pool \" << poolName_\n-\t\t\t\t\t   << \"(\" << available_.size() << \"/\" << capacity_ << \")\";\n-\t}\n-\n-\tdelete[] allocated_;\n-\tallocated_ = nullptr;\n-\tavailable_.clear();\n-\tcapacity_ = 0;\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n-\t\t\t\t   << \" deinit done\";\n-\n-\treturn 0;\n-}\n-\n-template<class ItemType>\n-int SharedItemPool<ItemType>::acquireItem(std::shared_ptr<ItemType> &item)\n-{\n-\titem.reset();\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tif (available_.empty()) {\n-\t\tLOG(SharedItemPool, Error) << \"Shared pool \" << poolName_\n-\t\t\t\t\t   << \"is empty\";\n-\t\treturn -ENOSYS;\n-\t}\n-\n-\tstd::shared_ptr<ItemType> sh(available_[0], deleter_);\n-\tavailable_.erase(available_.begin());\n-\titem = sh;\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n-\t\t\t\t   << \"acquire items \" << sh.get();\n-\treturn 0;\n-}\n-\n-template<class ItemType>\n-size_t SharedItemPool<ItemType>::availableItems()\n-{\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tsize_t ret = available_.size();\n-\treturn ret;\n-}\n-\n-template<class ItemType>\n-int SharedItemPool<ItemType>::_releaseItem(ItemType *item)\n-{\n-\tstd::lock_guard<std::mutex> l(mutex_);\n-\tif (resetter_)\n-\t\tresetter_(item);\n-\n-\tLOG(SharedItemPool, Debug) << \"Shared pool \" << poolName_\n-\t\t\t\t   << \"returning item \" << item;\n-\n-\tavailable_.push_back(item);\n-\treturn 0;\n-}\n-\n-template class SharedItemPool<ia_aiq_rgbs_grid>;\n-template class SharedItemPool<ia_aiq_af_grid>;\n-} /* namespace libcamera */\ndiff --git a/stats/shared_item_pool.h b/stats/shared_item_pool.h\ndeleted file mode 100644\nindex 89dc9b3..0000000\n--- a/stats/shared_item_pool.h\n+++ /dev/null\n@@ -1,114 +0,0 @@\n-/* SPDX-License-Identifier: Apache-2.0 */\n-/*\n- * Copyright (C) 2014-2018 Intel Corporation\n- *\n- * This implementation is highly derived from ChromeOS:\n- *   platform2/camera/hal/intel/ipu3/common/SharedItemPool.h\n- */\n-\n-#ifndef SHARED_ITEM_POOL_H\n-#define SHARED_ITEM_POOL_H\n-\n-#include <memory>\n-#include <mutex>\n-#include <pthread.h>\n-#include <vector>\n-\n-/**\n- * \\class SharedItemPool\n- *\n- * Pool of ref counted items. This class creates a pool of items and manages\n- * the acquisition of them. When all references to this item have disappeared\n- * The item is returned to the pool.\n- *\n- * This class is thread safe, i.e. it can be called from  multiple threads.\n- * When the element is recycled to the pool it can be reset via a client\n- * provided method.\n- *\n- */\n-\n-namespace libcamera {\n-\n-template<class ItemType>\n-class SharedItemPool\n-{\n-public:\n-\tSharedItemPool(const char *name = \"Unnamed\");\n-\t~SharedItemPool();\n-\n-\t/**\n-\t * Initializes the capacity of the pool. It allocates the objects.\n-\t * optionally it will take function to reset the item before recycling\n-\t * it to the pool.\n-\t * This method is thread safe.\n-\t *\n-\t * \\param capacity[IN]: Number of items the pool will hold\n-\t * \\param resetter[IN]: Function to reset the item before recycling to the\n-\t *                      pool.\n-\t * \\return -ENOSYS if trying to initialize twice\n-\t * \\return 0 If everything went ok.\n-\t */\n-\tint init(int32_t capacity, void (*resetter)(ItemType *) = nullptr);\n-\n-\tbool isFull();\n-\n-\t/**\n-\t * Free the resources of the pool\n-\t *\n-\t * \\return 0 on success\n-\t */\n-\tint deInit();\n-\n-\t/**\n-\t * Acquire an item from the pool.\n-\t * This method is thread safe. Access to the internal acquire/release\n-\t * methods are protected.\n-\t * BUT the thread-safety for the utilization of the item after it has been\n-\t * acquired is the user's responsibility.\n-\t * Be careful not to provide the same item to multiple threads that write\n-\t * into it.\n-\t *\n-\t * \\param item[OUT] shared pointer to an item.\n-\t * \\return 0 on success\n-\t */\n-\tint acquireItem(std::shared_ptr<ItemType> &item);\n-\n-\t/**\n-\t * Returns the number of currently available items\n-\t * It there would be issues acquiring the lock the method returns 0\n-\t * available items.\n-\t *\n-\t * \\return item count\n-\t */\n-\tsize_t availableItems();\n-\n-private:\n-\tint _releaseItem(ItemType *item);\n-\n-\tclass ItemDeleter\n-\t{\n-\tpublic:\n-\t\tItemDeleter(SharedItemPool *pool)\n-\t\t\t: mPool(pool) {}\n-\t\tvoid operator()(ItemType *item) const\n-\t\t{\n-\t\t\tmPool->_releaseItem(item);\n-\t\t}\n-\n-\tprivate:\n-\t\tSharedItemPool *mPool;\n-\t};\n-\n-\tstd::vector<ItemType *> available_; /* SharedItemPool doesn't have ownership */\n-\tItemType *allocated_;\n-\tsize_t capacity_;\n-\tItemDeleter deleter_;\n-\tstd::mutex mutex_; /* protects available_, allocated_, capacity_ */\n-\tconst char *poolName_;\n-\tvoid (*resetter_)(ItemType *);\n-};\n-\n-} /* namespace libcamera */\n-\n-#endif /* SHARED_ITEM_POOL_H */\n-\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "1/3"
    ]
}